PHP Class Webiny\Component\OAuth2\Bridge\AbstractOAuth2

This class implements the OAuth2Interface and adds some methods that ease the implementation of OAuth2 bridge libraries.
Inheritance: implements Webiny\Component\OAuth2\Bridge\OAuth2Interface, use trait Webiny\Component\StdLib\StdLibTrait
Show file Open project: Webiny/Framework Class Usage Examples

Protected Properties

Property Type Description
$accessTokenName string Name of the access token.
$clientId string OAuth2 Client ID.
$clientSecret string Client secret for defined Client ID.
$redirectUri string A URI where the user will be redirected after OAuth2 authorization.
$scope string Request scope, a comma-separated list of parameters.
$state string Request state.

Public Methods

Method Description
getAccessTokenName ( ) : string Returns the name of access token param. Its usually either 'access_token' or 'token' based on the OAuth2 server.
getClientId ( ) : string Get client id.
getClientSecret ( ) : string Get client secret.
getRedirectURI ( ) : string Get the defined redirect URI.
getScope ( ) : string Get the defined scope.
getServerClassName ( ) : string Returns the name of current OAuth2 server class.
getState ( ) : string Get the state parameter.
setOAuth2Server ( string $serverName, null | array $options = null ) Currently supported servers are: [facebook, google, linkedin].
setScope ( string $scope ) : void Set the request scope.
setState ( string $state ) : void. Set the state parameter.

Method Details

getAccessTokenName() public method

Returns the name of access token param. Its usually either 'access_token' or 'token' based on the OAuth2 server.
public getAccessTokenName ( ) : string
return string

getClientId() public method

Get client id.
public getClientId ( ) : string
return string Client id.

getClientSecret() public method

Get client secret.
public getClientSecret ( ) : string
return string Client secret.

getRedirectURI() public method

Get the defined redirect URI.
public getRedirectURI ( ) : string
return string Redirect URI.

getScope() public method

Get the defined scope.
public getScope ( ) : string
return string A comma separated list of parameters.

getServerClassName() public method

Returns the name of current OAuth2 server class.
public getServerClassName ( ) : string
return string

getState() public method

Get the state parameter.
public getState ( ) : string
return string State parameter

setOAuth2Server() public method

You can also paste 'custom' as server name, but in that case you must also provide the $options array that has auth_url and token_url as array keys. You can put variables like {CLIENT_ID}, {REDIRECT_URI}, {SCOPE} and {STATE} inside the auth_url and this function will replace them with current values.
public setOAuth2Server ( string $serverName, null | array $options = null )
$serverName string Name of the OAuth2 server for which you wish to get the auth_url and token_url.
$options null | array Optional array that you must provide in case of 'custom' server name.

setScope() public method

Set the request scope.
public setScope ( string $scope ) : void
$scope string A comma-separated list of parameters. Example: email,extender_permissions
return void

setState() public method

Set the state parameter.
public setState ( string $state ) : void.
$state string State name.
return void.

Property Details

$accessTokenName protected property

Name of the access token.
protected string $accessTokenName
return string

$clientId protected property

OAuth2 Client ID.
protected string $clientId
return string

$clientSecret protected property

Client secret for defined Client ID.
protected string $clientSecret
return string

$redirectUri protected property

A URI where the user will be redirected after OAuth2 authorization.
protected string $redirectUri
return string

$scope protected property

Request scope, a comma-separated list of parameters.
protected string $scope
return string

$state protected property

Request state.
protected string $state
return string