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

 Methods

Build new class Authentication, this provides user authentication for ApiChateaClient

__construct(\Ant\ChateaClient\Service\Client\ChateaOAuth2Client $client) 

Parameters

$client

\Ant\ChateaClient\Service\Client\ChateaOAuth2Client

The http client to know connect with api server

Get the http client for connect with api server

getClient() : \Ant\ChateaClient\Service\Client\ChateaOAuth2Client

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

string

The toke to revoke

Exceptions

\Ant\ChateaClient\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 $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

\Ant\ChateaClient\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 $authenticationInstande->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 $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

string

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

Exceptions

\Ant\ChateaClient\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 $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

string

The client name

$password

string

The secret credentials of user

Exceptions

\Ant\ChateaClient\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


 Properties

 

The http client to connect with api server

$client : \Ant\ChateaClient\Service\Client\ChateaOAuth2Client