PHP Class Overtrue\Socialite\Providers\AbstractProvider

Inheritance: implements Overtrue\Socialite\ProviderInterface
ファイルを表示 Open project: overtrue/socialite Class Usage Examples

Protected Properties

Property Type Description
$clientId string The client ID.
$clientSecret string The client secret.
$config Overtrue\Socialite\Config The configuration.
$encodingType The type of the encoding in the query.
$parameters array The custom parameters to be sent with the request.
$redirectUrl string The redirect URL.
$request Symfony\Component\HttpFoundation\Request The HTTP request instance.
$scopeSeparator string The separating character for the requested scopes.
$scopes array The scopes being requested.
$stateless boolean Indicates if the session state should be utilized.

Public Methods

Method Description
__construct ( Request $request, Config $config, string $clientId, string $clientSecret, string | null $redirectUrl = null ) Create a new provider instance.
getAccessToken ( string $code ) : AccessToken Get the access token for the given code.
getRedirectUrl ( ) : string Return the redirect url.
getRequest ( ) : Request Get the request instance.
redirect ( string $redirectUrl = null ) : RedirectResponse Redirect the user of the application to the provider's authentication screen.
scopes ( array $scopes ) Set the scopes of the requested access.
setRedirectUrl ( string $redirectUrl ) Set redirect url.
setRequest ( Request $request ) Set the request instance.
stateless ( ) Indicates that the provider should operate as stateless.
user ( Overtrue\Socialite\AccessTokenInterface $token = null )
with ( array $parameters ) Set the custom parameters of the request.
withRedirectUrl ( string $redirectUrl ) Set redirect url.

Protected Methods

Method Description
arrayItem ( array $array, string $key, mixed $default = null ) : mixed Return array item by key.
buildAuthUrlFromBase ( string $url, string $state ) : string Get the authentication URL for the provider.
formatScopes ( array $scopes, string $scopeSeparator ) : string Format the given scopes.
getAuthUrl ( string $state ) : string Get the authentication URL for the provider.
getCode ( ) : string Get the code from the request.
getCodeFields ( string | null $state = null ) : array Get the GET parameters for the code request.
getHttpClient ( ) : Client Get a fresh instance of the Guzzle HTTP client.
getTokenFields ( string $code ) : array Get the POST fields for the token request.
getTokenUrl ( ) : string Get the token URL for the provider.
getUserByToken ( Overtrue\Socialite\AccessTokenInterface $token ) : array Get the raw user for the given access token.
hasInvalidState ( ) : boolean Determine if the current request / session has a mismatching "state".
isStateless ( ) : boolean Determine if the provider is operating as stateless.
mapUserToObject ( array $user ) : Overtrue\Socialite\User Map the raw user array to a Socialite User instance.
parseAccessToken ( Psr\Http\Message\StreamInterface | array $body ) : AccessToken Get the access token from the token response body.
usesState ( ) : boolean Determine if the provider is operating with state.

Method Details

__construct() public method

Create a new provider instance.
public __construct ( Request $request, Config $config, string $clientId, string $clientSecret, string | null $redirectUrl = null )
$request Symfony\Component\HttpFoundation\Request
$config Overtrue\Socialite\Config
$clientId string
$clientSecret string
$redirectUrl string | null

arrayItem() protected method

Return array item by key.
protected arrayItem ( array $array, string $key, mixed $default = null ) : mixed
$array array
$key string
$default mixed
return mixed

buildAuthUrlFromBase() protected method

Get the authentication URL for the provider.
protected buildAuthUrlFromBase ( string $url, string $state ) : string
$url string
$state string
return string

formatScopes() protected method

Format the given scopes.
protected formatScopes ( array $scopes, string $scopeSeparator ) : string
$scopes array
$scopeSeparator string
return string

getAccessToken() public method

Get the access token for the given code.
public getAccessToken ( string $code ) : AccessToken
$code string
return Overtrue\Socialite\AccessToken

getAuthUrl() abstract protected method

Get the authentication URL for the provider.
abstract protected getAuthUrl ( string $state ) : string
$state string
return string

getCode() protected method

Get the code from the request.
protected getCode ( ) : string
return string

getCodeFields() protected method

Get the GET parameters for the code request.
protected getCodeFields ( string | null $state = null ) : array
$state string | null
return array

getHttpClient() protected method

Get a fresh instance of the Guzzle HTTP client.
protected getHttpClient ( ) : Client
return GuzzleHttp\Client

getRedirectUrl() public method

Return the redirect url.
public getRedirectUrl ( ) : string
return string

getRequest() public method

Get the request instance.
public getRequest ( ) : Request
return Symfony\Component\HttpFoundation\Request

getTokenFields() protected method

Get the POST fields for the token request.
protected getTokenFields ( string $code ) : array
$code string
return array

getTokenUrl() abstract protected method

Get the token URL for the provider.
abstract protected getTokenUrl ( ) : string
return string

getUserByToken() abstract protected method

Get the raw user for the given access token.
abstract protected getUserByToken ( Overtrue\Socialite\AccessTokenInterface $token ) : array
$token Overtrue\Socialite\AccessTokenInterface
return array

hasInvalidState() protected method

Determine if the current request / session has a mismatching "state".
protected hasInvalidState ( ) : boolean
return boolean

isStateless() protected method

Determine if the provider is operating as stateless.
protected isStateless ( ) : boolean
return boolean

mapUserToObject() abstract protected method

Map the raw user array to a Socialite User instance.
abstract protected mapUserToObject ( array $user ) : Overtrue\Socialite\User
$user array
return Overtrue\Socialite\User

parseAccessToken() protected method

Get the access token from the token response body.
protected parseAccessToken ( Psr\Http\Message\StreamInterface | array $body ) : AccessToken
$body Psr\Http\Message\StreamInterface | array
return Overtrue\Socialite\AccessToken

redirect() public method

Redirect the user of the application to the provider's authentication screen.
public redirect ( string $redirectUrl = null ) : RedirectResponse
$redirectUrl string
return Symfony\Component\HttpFoundation\RedirectResponse

scopes() public method

Set the scopes of the requested access.
public scopes ( array $scopes )
$scopes array

setRedirectUrl() public method

Set redirect url.
public setRedirectUrl ( string $redirectUrl )
$redirectUrl string

setRequest() public method

Set the request instance.
public setRequest ( Request $request )
$request Symfony\Component\HttpFoundation\Request

stateless() public method

Indicates that the provider should operate as stateless.
public stateless ( )

user() public method

public user ( Overtrue\Socialite\AccessTokenInterface $token = null )
$token Overtrue\Socialite\AccessTokenInterface

usesState() protected method

Determine if the provider is operating with state.
protected usesState ( ) : boolean
return boolean

with() public method

Set the custom parameters of the request.
public with ( array $parameters )
$parameters array

withRedirectUrl() public method

Set redirect url.
public withRedirectUrl ( string $redirectUrl )
$redirectUrl string

Property Details

$clientId protected_oe property

The client ID.
protected string $clientId
return string

$clientSecret protected_oe property

The client secret.
protected string $clientSecret
return string

$config protected_oe property

The configuration.
protected Config,Overtrue\Socialite $config
return Overtrue\Socialite\Config

$encodingType protected_oe property

The type of the encoding in the query.
protected $encodingType

$parameters protected_oe property

The custom parameters to be sent with the request.
protected array $parameters
return array

$redirectUrl protected_oe property

The redirect URL.
protected string $redirectUrl
return string

$request protected_oe property

The HTTP request instance.
protected Request,Symfony\Component\HttpFoundation $request
return Symfony\Component\HttpFoundation\Request

$scopeSeparator protected_oe property

The separating character for the requested scopes.
protected string $scopeSeparator
return string

$scopes protected_oe property

The scopes being requested.
protected array $scopes
return array

$stateless protected_oe property

Indicates if the session state should be utilized.
protected bool $stateless
return boolean