Specifies a client that provides user authentication for ApiChateaClient sites that use OAuth2-based authentication.

author Xabier Fernández Rodríguez in Ant-Web S.L.
package Ant\ChateaClient\Client
see
see
see
see

 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

array

Associative 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

string

The toke to revoke

Exceptions

\Ant\ChateaClient\Service\Client\InvalidArgumentException This exception is thrown if any parameter has errors
\Ant\ChateaClient\Service\Client\AuthenticationException This exception is thrown if you do not credentials or you cannot use this method

Returns

stringMessage sucessfully if can revoke token | Message with error in json format

Examples


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

\Ant\ChateaClient\Service\Client\InvalidArgumentException This exception is thrown if any parameter has errors
\Ant\ChateaClient\Service\Client\AuthenticationException This exception is thrown if you do not credentials or you cannot use this method

Returns

arraystringAssociative array with client credentials | Message with error in json format

Examples


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

\Ant\ChateaClient\Service\Client\AuthenticationException This exception is thrown if you do not credentials or you cannot use this method

Returns

arraystringAssociative array with client credentials | Message with error in json format

Examples


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

string

The client refresh token that you obtain in first request of credentials.

Exceptions

\Ant\ChateaClient\Service\Client\InvalidArgumentException This exception is thrown if any parameter has errors
\Ant\ChateaClient\Service\Client\AuthenticationException This exception is thrown if you do not credentials or you cannot use this method

Returns

arraystringAssociative array with client credentials | Message with error in json format

Examples


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

string

The client name

$password

string

The secret credentials of user

Exceptions

\Ant\ChateaClient\Service\Client\InvalidArgumentException This exception is thrown if any parameter has errors
\Ant\ChateaClient\Service\Client\AuthenticationException This exception is thrown if you do not credentials or you cannot use this method

Returns

arraystringAssociative array with client credentials | Message with error in json format

Examples