DeveloperKey
extends AbstractBaseApi
in package
Canvas Developer Keys API
Manages Canvas API keys used for OAuth access. This API handles both Canvas API keys and LTI 1.3 registrations, though this implementation focuses on Canvas API keys.
Developer Keys follow Account-as-default context pattern:
- Direct calls use Account context from Config::getAccountId()
- Mixed endpoint routing: CREATE/LIST use account context, UPDATE/DELETE use direct ID
Tags
Table of Contents
Constants
- AUDIENCE_EXTERNAL = 'external'
- AUDIENCE_INTERNAL = 'internal'
- STATE_ACTIVE = 'active'
- STATE_DELETED = 'deleted'
- STATE_INACTIVE = 'inactive'
Properties
- $accessTokenCount : int|null
- $accountName : string|null
- $allowIncludes : bool|null
- $apiKey : string|null
- $clientCredentialsAudience : string|null
- $createdAt : string|null
- $email : string|null
- $iconUrl : string|null
- $id : int|null
- $isLtiKey : bool|null
- $isLtiRegistration : bool|null
- $lastUsedAt : string|null
- $ltiRegistration : array<string, mixed>|null
- $name : string|null
- $notes : string|null
- $publicJwk : array<string, mixed>|null
- $publicJwkUrl : string|null
- $redirectUri : string|null
- $redirectUris : array<string|int, string>|null
- $requireScopes : bool|null
- $scopes : array<string|int, string>|null
- $testClusterOnly : bool|null
- $toolConfiguration : array<string, mixed>|null
- $updatedAt : string|null
- $userId : string|null
- $userName : string|null
- $vendorCode : string|null
- $visible : bool|null
- $workflowState : string|null
- $apiClient : HttpClientInterface
- $methodAliases : array<string|int, mixed>
- Define method aliases
Methods
- __callStatic() : mixed
- Magic method to handle function aliases
- __construct() : mixed
- BaseApi constructor.
- all() : array<string|int, static>
- Get all pages of results
- allowsIncludes() : bool
- Check if key allows includes parameters
- create() : self
- Create a new developer key Uses account-scoped endpoint: POST /api/v1/accounts/:account_id/developer_keys
- delete() : array<string, mixed>
- Delete a developer key Uses direct ID endpoint: DELETE /api/v1/developer_keys/:id
- find() : self
- Find a developer key by ID Note: Canvas doesn't have a direct GET endpoint for individual developer keys This method fetches all keys and filters by ID
- get() : array<string|int, self>
- Get all developer keys using account context Uses account-scoped endpoint: GET /api/v1/accounts/:account_id/developer_keys
- getClientCredentialsAudienceDisplay() : string|null
- Get client credentials audience display name
- getPaginated() : PaginatedResponse
- Get paginated developer keys
- getRedirectUrisString() : string|null
- Get redirect URIs as comma-separated string
- getScopesString() : string|null
- Get scopes as comma-separated string
- getWithInherited() : array<string|int, self>
- Get developer keys with inherited keys from Site Admin
- isActive() : bool
- Check if this developer key is active
- isApiKey() : bool
- Check if this is a Canvas API key (vs LTI key)
- isDeleted() : bool
- Check if this developer key is deleted
- isInactive() : bool
- Check if this developer key is inactive
- isLti() : bool
- Check if this is an LTI key (vs Canvas API key)
- isTestClusterOnly() : bool
- Check if key is restricted to test cluster only
- paginate() : PaginationResult
- Get paginated results with metadata
- remove() : array<string, mixed>
- Delete this developer key instance
- requiresScopes() : bool
- Check if key requires scopes in token requests
- save() : self
- Update this developer key instance
- setApiClient() : void
- Set the API client
- update() : self
- Update an existing developer key Uses direct ID endpoint: PUT /api/v1/developer_keys/:id
- castValue() : DateTime|mixed
- Cast a value to the correct type
- checkApiClient() : void
- Check if the API client is set, if not, instantiate a new one
- convertPaginatedResponseToModels() : array<string|int, static>
- Helper method to convert paginated response data to model instances
- createConfiguredHttpClient() : HttpClient
- Create an HttpClient with configured middleware
- createPaginationResult() : PaginationResult
- Helper method to create PaginationResult from paginated response
- getEndpoint() : string
- Get the base endpoint for account-scoped operations (CREATE/LIST)
- getPaginatedResponse() : PaginatedResponse
- Helper method to get paginated response from API endpoint
- populate() : void
- Populate the object with new data
- toDtoArray() : array<string|int, mixed>
- Convert the object to an array
Constants
AUDIENCE_EXTERNAL
public
mixed
AUDIENCE_EXTERNAL
= 'external'
AUDIENCE_INTERNAL
public
mixed
AUDIENCE_INTERNAL
= 'internal'
STATE_ACTIVE
public
mixed
STATE_ACTIVE
= 'active'
STATE_DELETED
public
mixed
STATE_DELETED
= 'deleted'
STATE_INACTIVE
public
mixed
STATE_INACTIVE
= 'inactive'
Properties
$accessTokenCount
public
int|null
$accessTokenCount
= null
$accountName
public
string|null
$accountName
= null
$allowIncludes
public
bool|null
$allowIncludes
= null
$apiKey
public
string|null
$apiKey
= null
$clientCredentialsAudience
public
string|null
$clientCredentialsAudience
= null
$createdAt
public
string|null
$createdAt
= null
public
string|null
$email
= null
$iconUrl
public
string|null
$iconUrl
= null
$id
public
int|null
$id
= null
$isLtiKey
public
bool|null
$isLtiKey
= null
$isLtiRegistration
public
bool|null
$isLtiRegistration
= null
$lastUsedAt
public
string|null
$lastUsedAt
= null
$ltiRegistration
public
array<string, mixed>|null
$ltiRegistration
= null
$name
public
string|null
$name
= null
$notes
public
string|null
$notes
= null
$publicJwk
public
array<string, mixed>|null
$publicJwk
= null
$publicJwkUrl
public
string|null
$publicJwkUrl
= null
$redirectUri
public
string|null
$redirectUri
= null
$redirectUris
public
array<string|int, string>|null
$redirectUris
= null
$requireScopes
public
bool|null
$requireScopes
= null
$scopes
public
array<string|int, string>|null
$scopes
= null
$testClusterOnly
public
bool|null
$testClusterOnly
= null
$toolConfiguration
public
array<string, mixed>|null
$toolConfiguration
= null
$updatedAt
public
string|null
$updatedAt
= null
$userId
public
string|null
$userId
= null
$userName
public
string|null
$userName
= null
$vendorCode
public
string|null
$vendorCode
= null
$visible
public
bool|null
$visible
= null
$workflowState
public
string|null
$workflowState
= null
$apiClient
protected
static HttpClientInterface
$apiClient
= null
$methodAliases
Define method aliases
protected
static array<string|int, mixed>
$methodAliases
= ['get' => ['fetch', 'list', 'fetchAll'], 'all' => ['fetchAllPages', 'getAll'], 'paginate' => ['getPaginated', 'withPagination', 'fetchPage'], 'find' => ['one', 'getOne']]
Methods
__callStatic()
Magic method to handle function aliases
public
static __callStatic(string $name, array<string|int, mixed> $arguments) : mixed
Parameters
- $name : string
- $arguments : array<string|int, mixed>
Tags
__construct()
BaseApi constructor.
public
__construct(array<string|int, mixed> $data) : mixed
Parameters
- $data : array<string|int, mixed>
all()
Get all pages of results
public
static all([array<string, mixed> $params = [] ]) : array<string|int, static>
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Return values
array<string|int, static>allowsIncludes()
Check if key allows includes parameters
public
allowsIncludes() : bool
Return values
boolcreate()
Create a new developer key Uses account-scoped endpoint: POST /api/v1/accounts/:account_id/developer_keys
public
static create(array<string, mixed>|CreateDeveloperKeyDTO $data) : self
Parameters
- $data : array<string, mixed>|CreateDeveloperKeyDTO
-
Developer key creation data
Tags
Return values
self —The created DeveloperKey instance
delete()
Delete a developer key Uses direct ID endpoint: DELETE /api/v1/developer_keys/:id
public
static delete(int $id) : array<string, mixed>
Parameters
- $id : int
-
The developer key ID
Tags
Return values
array<string, mixed> —The deleted developer key data
find()
Find a developer key by ID Note: Canvas doesn't have a direct GET endpoint for individual developer keys This method fetches all keys and filters by ID
public
static find(int $id[, array<string|int, mixed> $params = [] ]) : self
Parameters
- $id : int
-
The developer key ID
- $params : array<string|int, mixed> = []
-
Optional query parameters
Tags
Return values
self —The DeveloperKey instance
get()
Get all developer keys using account context Uses account-scoped endpoint: GET /api/v1/accounts/:account_id/developer_keys
public
static get([array<string, mixed> $params = [] ]) : array<string|int, self>
Parameters
- $params : array<string, mixed> = []
-
Query parameters (e.g., 'inherited' => true)
Return values
array<string|int, self> —Array of DeveloperKey instances
getClientCredentialsAudienceDisplay()
Get client credentials audience display name
public
getClientCredentialsAudienceDisplay() : string|null
Return values
string|nullgetPaginated()
Get paginated developer keys
public
static getPaginated([array<string, mixed> $params = [] ]) : PaginatedResponse
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Return values
PaginatedResponsegetRedirectUrisString()
Get redirect URIs as comma-separated string
public
getRedirectUrisString() : string|null
Return values
string|nullgetScopesString()
Get scopes as comma-separated string
public
getScopesString() : string|null
Return values
string|nullgetWithInherited()
Get developer keys with inherited keys from Site Admin
public
static getWithInherited() : array<string|int, self>
Return values
array<string|int, self> —Array of DeveloperKey instances including inherited keys
isActive()
Check if this developer key is active
public
isActive() : bool
Return values
boolisApiKey()
Check if this is a Canvas API key (vs LTI key)
public
isApiKey() : bool
Return values
boolisDeleted()
Check if this developer key is deleted
public
isDeleted() : bool
Return values
boolisInactive()
Check if this developer key is inactive
public
isInactive() : bool
Return values
boolisLti()
Check if this is an LTI key (vs Canvas API key)
public
isLti() : bool
Return values
boolisTestClusterOnly()
Check if key is restricted to test cluster only
public
isTestClusterOnly() : bool
Return values
boolpaginate()
Get paginated results with metadata
public
static paginate([array<string, mixed> $params = [] ]) : PaginationResult
Parameters
- $params : array<string, mixed> = []
-
Query parameters
Return values
PaginationResultremove()
Delete this developer key instance
public
remove() : array<string, mixed>
Tags
Return values
array<string, mixed> —The deleted developer key data
requiresScopes()
Check if key requires scopes in token requests
public
requiresScopes() : bool
Return values
boolsave()
Update this developer key instance
public
save(array<string, mixed>|UpdateDeveloperKeyDTO $data) : self
Parameters
- $data : array<string, mixed>|UpdateDeveloperKeyDTO
-
Update data
Tags
Return values
self —The updated DeveloperKey instance
setApiClient()
Set the API client
public
static setApiClient(HttpClientInterface $apiClient) : void
Parameters
- $apiClient : HttpClientInterface
update()
Update an existing developer key Uses direct ID endpoint: PUT /api/v1/developer_keys/:id
public
static update(int $id, array<string, mixed>|UpdateDeveloperKeyDTO $data) : self
Parameters
- $id : int
-
The developer key ID
- $data : array<string, mixed>|UpdateDeveloperKeyDTO
-
Update data
Tags
Return values
self —The updated DeveloperKey instance
castValue()
Cast a value to the correct type
protected
castValue(string $key, mixed $value) : DateTime|mixed
Parameters
- $key : string
- $value : mixed
Tags
Return values
DateTime|mixedcheckApiClient()
Check if the API client is set, if not, instantiate a new one
protected
static checkApiClient() : void
convertPaginatedResponseToModels()
Helper method to convert paginated response data to model instances
protected
static convertPaginatedResponseToModels(PaginatedResponse $paginatedResponse) : array<string|int, static>
Parameters
- $paginatedResponse : PaginatedResponse
Return values
array<string|int, static>createConfiguredHttpClient()
Create an HttpClient with configured middleware
protected
static createConfiguredHttpClient() : HttpClient
Return values
HttpClientcreatePaginationResult()
Helper method to create PaginationResult from paginated response
protected
static createPaginationResult(PaginatedResponse $paginatedResponse) : PaginationResult
Parameters
- $paginatedResponse : PaginatedResponse
Return values
PaginationResultgetEndpoint()
Get the base endpoint for account-scoped operations (CREATE/LIST)
protected
static getEndpoint() : string
Return values
string —The API endpoint
getPaginatedResponse()
Helper method to get paginated response from API endpoint
protected
static getPaginatedResponse(string $endpoint[, array<string|int, mixed> $params = [] ]) : PaginatedResponse
Parameters
- $endpoint : string
-
The API endpoint path
- $params : array<string|int, mixed> = []
-
Query parameters for the request
Return values
PaginatedResponsepopulate()
Populate the object with new data
protected
populate(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
Tags
toDtoArray()
Convert the object to an array
protected
toDtoArray() : array<string|int, mixed>