Specifies a client that provides user authentication for ApiChateaClient sites that use OAuth2-based authentication.
Methods
Build new class ChateaOAuth2Client, this provides user authentication for ApiChateaClient
factory(array $config) : \Ant\ChateaClient\Service\Client\ChateaOAuth2Client | \Guzzle\Service\Client
Static
Parameters
$config
arrayAssociative array can configure the client. The parameters are:
client_id The public key of client. This parameter is required
secret The private key of client. This parameter is required
base_url The server endpoind url. This parameter is optional
Accept The accept header, default value is json. This parameter is optional
environment Set mode production [prod] or developing [dev] default value is prod. This parameter is optional
scheme Set server schema communication [http|https] for default https. This parameter is optional
subdomain Set server subdomain if this exist. For default is api. This parameter is optional
Returns
The public key of client
getClientId() : string
Returns
stringThe public key of client
The private key of client
getSecret() : string
Returns
stringThe private key of client
Disable the service credentials as well as the session.
revokeToken(string $access_token) : string
| example |
client credentials
$clientInstande->revokeToken('access-token-demo');
//output
Access token revoked |
Parameters
$access_token
stringThe toke to revoke
Exceptions
Returns
stringMessage sucessfully if can revoke token | Message with error in json format
Enables the user to get service credentials as well as service credential
authentication settings for use on the client side of communication.
withAuthorizationCode(mixed $auth_code, mixed $redirect_uri) : array | string
| example |
client credentials
$clientInstande->withAuthorizationCode('auth-code-demo','http://www.chateagratis.net');
array("access_token" => access-token-demo,
"expires_in" => 3600,
"token_type" => bearer,
"scope" => password,
"refresh_token" => refresh-token-demo
); |
Parameters
$auth_code
The unique client code
$redirect_uri
The url to redirect after you obtain client credentials
Exceptions
Returns
arraystringAssociative array with client credentials | Message with error in json format
Enables the apps to get service credentials as well as service credential
authentication settings for use on the apps side of communication.
withClientCredentials() : array | string
| example |
client credentials
$clientInstande->withClientCredentials();
array("access_token" => access-token-demo,
"expires_in" => 3600,
"token_type" => bearer,
"scope" => password,
"refresh_token" => refresh-token-demo
); |
Exceptions
Returns
arraystringAssociative array with client credentials | Message with error in json format
After the client has been authorized for access, they can use a refresh token to get a new access token.
withRefreshToken(string $refresh_token) : array | string
| example |
client credentials
$clientInstande->withRefreshToken('refresh-token-demo');
array("access_token" => access-token-demo,
"expires_in" => 3600,
"token_type" => bearer,
"scope" => password,
"refresh_token" => refresh-token-demo
); |
Parameters
$refresh_token
stringThe client refresh token that you obtain in first request of credentials.
Exceptions
Returns
arraystringAssociative array with client credentials | Message with error in json format
Enables the user to get service credentials as well as service credential
authentication settings for use on the client side of communication.
withUserCredentials(string $username, string $password) : array | string
| example |
client credentials
$clientInstande->withUserCredentials('username','password');
array("access_token" => access-token-demo,
"expires_in" => 3600,
"token_type" => bearer,
"scope" => password,
"refresh_token" => refresh-token-demo
); |
Parameters
$username
stringThe client name
$password
stringThe secret credentials of user
Exceptions
Returns
arraystringAssociative array with client credentials | Message with error in json format