Specifies a client that provides user authentication for ApiChateaClient sites that use OAuth2-based authentication.
Methods
Build new class Authentication, this provides user authentication for ApiChateaClient
__construct(\Ant\ChateaClient\Service\Client\ChateaOAuth2Client $client)
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
$authenticationInstande->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
$authenticationInstande->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
$authenticationInstande->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
$authenticationInstande->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
$authenticationInstande->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
Properties