|
| initAuthCode ($auto_redirect) |
|
| validateResponseState ($response) |
|
| finalAuthCode ($response) |
|
| initResourceOwner () |
|
| initClientCredentials () |
|
Implementation of OAUth2 flow
OneCRM\APIClient\AuthorizationFlow::__construct |
( |
|
$url, |
|
|
array |
$options = [] |
|
) |
| |
Constructor.
Flow parameters passed in $options depend on authorization flow used:
client_id
: API client ID. Required. Can be omited if ONECRM_CLIENT_ID
environment variable is set.
client_secret
: API client secret. Required. Can be omited if ONECRM_CLIENT_SECRET
environment variable is set.
redirect_uri
: Redirect URI. Required for Authorization Code flow. Can be omited if ONECRM_REDIRECT_URI
environment variable is set.
username
: 1CRM user name. Required for Resource Owner Password Credentials flow. Can be omited if ONECRM_USERNAME
environment variable is set.
password
: 1CRM user password. Required for Resource Owner Password Credentials flow. Can be omited if ONECRM_PASSWORD
environment variable is set.
scope
: Authorization request scope. Optional, defaults to profile
owner_type
: user
or contact
. Default value is user
state
: CSRF token. Optional
- Parameters
-
OneCRM\APIClient\AuthorizationFlow::finalize |
( |
array |
$response = null | ) |
|
Finalizes Oauth2 Authorization Code Grant flow
This method must be called when user returns to redirect_url
after granting access to the application.
- Parameters
-
$response | Normally, this can be omited to use parameters passed by 1CRM OAuth server via query string. |
- Returns
- OAuth2 access token
- Exceptions
-
OneCRM\APIClient\AuthorizationFlow::init |
( |
|
$grant, |
|
|
|
$auto_redirect = false |
|
) |
| |
Starts OAuth2 flow.
Use this method to start authorization flow and obtain OAuth2 access token.
Valid values for $grant
parameters are:
authorization_code
: starts Authorization Code Grant flow
password
: obtains an access token using Resource Owner Password Credentials Grant flow
client_credentials
: obtains an access token using Client Credentials Grant flow
When password
or client_credentials
are used, this method returns an access token directly.
When authorization_code
is used, this method returns an URI the user must visit to complete the authorization flow. Additionally, you can pass true
in $auto_redirect
to automatically send Location:
header for redirect.
- Exceptions
-
OneCRM\APIClient\AuthorizationFlow::refreshToken |
( |
|
$refreshToken | ) |
|
Refreshes expired access token
- Parameters
-
$refreshToken | Refresh token |
- Returns
- New access token
- Exceptions
-
The documentation for this class was generated from the following file:
- src/APIClient/AuthorizationFlow.php