OAuth ​
- Type
- Class
- Namespace
- craft\services
- Inherits
- craft\services\OAuth » yii\base\Component » yii\base\BaseObject
- Implements
- yii\base\Configurable
Shared OAuth authorization and resource authentication.
@since 5.12.0
Public Properties ​
| Property | Description |
|---|---|
| behaviors | \yii\base\Behavior<static>[] – List of behaviors attached to this component. |
| resources | array<string,resource> |
resources ​
- Type
array<string,resource>- Default value
null- Access
- Read-only
Public Methods ​
| Method | Description |
|---|---|
| __call() | Calls the named method which is not a class method. |
| __clone() | This method is called after the object is created by cloning an existing one. |
| __construct() | Constructor. |
| __get() | Returns the value of a component property. |
| __isset() | Checks if a property is set, i.e. defined and not null. |
| __set() | Sets the value of a component property. |
| __unset() | Sets a component property to be null. |
| approveScopes() | Narrows an authorization request to the access level the user chose, falling back to the narrowest level they may choose. |
| attachBehavior() | Attaches a behavior to this component. |
| attachBehaviors() | Attaches a list of behaviors to the component. |
| authenticate() | Authenticates a resource's bearer token and requires every supplied scope. |
| authorizedUser() | |
| behaviors() | Returns a list of behaviors that this component should behave as. |
| canGetProperty() | Returns a value indicating whether a property can be read. |
| canSetProperty() | Returns a value indicating whether a property can be set. |
| className() | Returns the fully qualified name of this class. |
| detachBehavior() | Detaches a behavior from the component. |
| detachBehaviors() | Detaches all behaviors from the component. |
| ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. |
| generateKeys() | Generate the default keys explicitly, without replacing existing keys. |
| getBehavior() | Returns the named behavior object. |
| getBehaviors() | Returns all behaviors attached to this component. |
| getResource() | |
| getResources() | |
| hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. |
| hasKeys() | Returns whether valid signing keys are available, so tokens can be issued and verified. |
| hasMethod() | Returns a value indicating whether a method is defined. |
| hasProperty() | Returns a value indicating whether a property is defined for this component. |
| init() | Initializes the object. |
| issuer() | |
| metadata() | |
| off() | Detaches an existing event handler from this component. |
| on() | Attaches an event handler to an event. |
| protectedResourceMetadata() | |
| resource() | |
| resourceMetadataUrl() | |
| resourceServer() | |
| reuseConsent() | Whether the user already approved the request's scopes for its client. If so, narrows the request to the access level they chose before. |
| server() | |
| trigger() | Triggers an event. |
| url() | Returns the URL to an OAuth endpoint for the current request. |
approveScopes() ​
Narrows an authorization request to the access level the user chose, falling back to the narrowest level they may choose.
Arguments ​
$request$resource$user$level
authenticate() ​
Authenticates a resource's bearer token and requires every supplied scope.
Arguments ​
$request$resource$requiredScopes(string[])$scopes(array, null) – Set to the scope IDs the token grants.
authorizedUser() ​
Arguments ​
$id$resource
generateKeys() ​
Generate the default keys explicitly, without replacing existing keys.
Arguments ​
$force
getResource() ​
Arguments ​
$id
getResources() ​
Returns ​
array<string,resource>
hasKeys() ​
- Since
- 5.12.1
Returns whether valid signing keys are available, so tokens can be issued and verified.
issuer() ​
Arguments ​
$resource
metadata() ​
Arguments ​
$resource
protectedResourceMetadata() ​
Arguments ​
$resource
resource() ​
Arguments ​
$resource
resourceMetadataUrl() ​
Arguments ​
$resource
resourceServer() ​
Arguments ​
$resource
reuseConsent() ​
Whether the user already approved the request's scopes for its client. If so, narrows the request to the access level they chose before.
Arguments ​
$request$resource
server() ​
Arguments ​
$resource
url() ​
Returns the URL to an OAuth endpoint for the current request.
Front-end requests get a site action URL, so the authorization flow can stay on the front end. Discovery metadata and the issuer don’t vary by request; see \craft\services\serverUrl().
Arguments ​
Returns ​
Constants ​
| Constant | Description |
|---|---|
PERSONAL_ACCESS_PROVIDER | The user provider Craft 6’s Passport guard uses, which Passport matches personal access clients against. |
Events ​
EVENT_REGISTER_RESOURCES ​
Registers protected API definitions.