Overview

Namespaces

  • Docta
    • MercadoLibre
      • OAuth2
        • Client
  • GuzzleHttp
    • Cookie
    • Exception
    • Handler
    • Promise
    • Psr7
  • League
    • OAuth2
      • Client
        • Grant
          • Exception
        • Provider
          • Exception
        • Token
        • Tool
  • Psr
    • Http
      • Message

Classes

  • AbstractProvider
  • GenericProvider
  • GenericResourceOwner

Interfaces

  • ResourceOwnerInterface
  • Overview
  • Namespace
  • Class
  • Download

Class AbstractProvider

Represents a service provider (authorization server).

League\OAuth2\Client\Provider\AbstractProvider uses League\OAuth2\Client\Tool\ArrayAccessorTrait, League\OAuth2\Client\Tool\QueryBuilderTrait

Direct known subclasses

Docta\MercadoLibre\OAuth2\Client\Provider, League\OAuth2\Client\Provider\GenericProvider
Abstract
Namespace: League\OAuth2\Client\Provider
Link: Roles (RFC 6749, ยง1.1)
Located at src/Provider/AbstractProvider.php
Methods summary
public
# __construct( array $options = [], array $collaborators = [] )

Constructs an OAuth 2.0 service provider.

Constructs an OAuth 2.0 service provider.

Parameters

$options

An array of options to set on this provider. Options include clientId, clientSecret, redirectUri, and state. Individual providers may introduce more options, as needed.

$collaborators

An array of collaborators that may be used to override this provider's default behavior. Collaborators include grantFactory, requestFactory, and httpClient. Individual providers may introduce more collaborators, as needed.

protected array
# getAllowedClientOptions( array $options )

Returns the list of options that can be passed to the HttpClient

Returns the list of options that can be passed to the HttpClient

Parameters

$options

An array of options to set on this provider. Options include clientId, clientSecret, redirectUri, and state. Individual providers may introduce more options, as needed.

Returns

array
The options to pass to the HttpClient constructor
public League\OAuth2\Client\Provider\AbstractProvider
# setGrantFactory( League\OAuth2\Client\Grant\GrantFactory $factory )

Sets the grant factory instance.

Sets the grant factory instance.

Parameters

$factory

Returns

League\OAuth2\Client\Provider\AbstractProvider
public League\OAuth2\Client\Grant\GrantFactory
# getGrantFactory( )

Returns the current grant factory instance.

Returns the current grant factory instance.

Returns

League\OAuth2\Client\Grant\GrantFactory
public League\OAuth2\Client\Provider\AbstractProvider
# setRequestFactory( League\OAuth2\Client\Tool\RequestFactory $factory )

Sets the request factory instance.

Sets the request factory instance.

Parameters

$factory

Returns

League\OAuth2\Client\Provider\AbstractProvider
public League\OAuth2\Client\Tool\RequestFactory
# getRequestFactory( )

Returns the request factory instance.

Returns the request factory instance.

Returns

League\OAuth2\Client\Tool\RequestFactory
public League\OAuth2\Client\Provider\AbstractProvider
# setHttpClient( GuzzleHttp\ClientInterface $client )

Sets the HTTP client instance.

Sets the HTTP client instance.

Parameters

$client

Returns

League\OAuth2\Client\Provider\AbstractProvider
public GuzzleHttp\ClientInterface
# getHttpClient( )

Returns the HTTP client instance.

Returns the HTTP client instance.

Returns

GuzzleHttp\ClientInterface
public string
# getState( )

Returns the current value of the state parameter.

Returns the current value of the state parameter.

This can be accessed by the redirect handler during authorization.

Returns

string
abstract public string
# getBaseAuthorizationUrl( )

Returns the base URL for authorizing a client.

Returns the base URL for authorizing a client.

Eg. https://oauth.service.com/authorize

Returns

string
abstract public string
# getBaseAccessTokenUrl( array $params )

Returns the base URL for requesting an access token.

Returns the base URL for requesting an access token.

Eg. https://oauth.service.com/token

Parameters

$params

Returns

string
abstract public string
# getResourceOwnerDetailsUrl( League\OAuth2\Client\Token\AccessToken $token )

Returns the URL for requesting the resource owner's details.

Returns the URL for requesting the resource owner's details.

Parameters

$token

Returns

string
protected string
# getRandomState( integer $length = 32 )

Returns a new random string to use as the state parameter in an authorization flow.

Returns a new random string to use as the state parameter in an authorization flow.

Parameters

$length
Length of the random string to be generated.

Returns

string
abstract protected array
# getDefaultScopes( )

Returns the default scopes used by this provider.

Returns the default scopes used by this provider.

This should only be the scopes that are required to request the details of the resource owner, rather than all the available scopes.

Returns

array
protected string
# getScopeSeparator( )

Returns the string that should be used to separate scopes when building the URL for requesting an access token.

Returns the string that should be used to separate scopes when building the URL for requesting an access token.

Returns

string
Scope separator, defaults to ','
protected array
# getAuthorizationParameters( array $options )

Returns authorization parameters based on provided options.

Returns authorization parameters based on provided options.

Parameters

$options

Returns

array
Authorization parameters
protected string
# getAuthorizationQuery( array $params )

Builds the authorization URL's query string.

Builds the authorization URL's query string.

Parameters

$params
Query parameters

Returns

string
Query string
public string
# getAuthorizationUrl( array $options = [] )

Builds the authorization URL.

Builds the authorization URL.

Parameters

$options

Returns

string
Authorization URL
public mixed
# authorize( array $options = [], callable $redirectHandler = null )

Redirects the client for authorization.

Redirects the client for authorization.

Parameters

$options
$redirectHandler

Returns

mixed
protected string
# appendQuery( string $url, string $query )

Appends a query string to a URL.

Appends a query string to a URL.

Parameters

$url
The URL to append the query to
$query
The HTTP query string

Returns

string
The resulting URL
protected string
# getAccessTokenMethod( )

Returns the method to use when requesting an access token.

Returns the method to use when requesting an access token.

Returns

string
HTTP method
protected string|null
# getAccessTokenResourceOwnerId( )

Returns the key used in the access token response to identify the resource owner.

Returns the key used in the access token response to identify the resource owner.

Returns

string|null
Resource owner identifier key
protected string
# getAccessTokenQuery( array $params )

Builds the access token URL's query string.

Builds the access token URL's query string.

Parameters

$params
Query parameters

Returns

string
Query string
protected League\OAuth2\Client\Grant\AbstractGrant
# verifyGrant( League\OAuth2\Client\Grant\AbstractGrant|string $grant )

Checks that a provided grant is valid, or attempts to produce one if the provided grant is a string.

Checks that a provided grant is valid, or attempts to produce one if the provided grant is a string.

Parameters

$grant

Returns

League\OAuth2\Client\Grant\AbstractGrant
protected string
# getAccessTokenUrl( array $params )

Returns the full URL to use when requesting an access token.

Returns the full URL to use when requesting an access token.

Parameters

$params
Query parameters

Returns

string
protected string
# getAccessTokenBody( array $params )

Returns the request body for requesting an access token.

Returns the request body for requesting an access token.

Parameters

$params

Returns

string
protected array
# getAccessTokenOptions( array $params )

Builds request options used for requesting an access token.

Builds request options used for requesting an access token.

Parameters

$params

Returns

array
protected Psr\Http\Message\RequestInterface
# getAccessTokenRequest( array $params )

Returns a prepared request for requesting an access token.

Returns a prepared request for requesting an access token.

Parameters

$params
Query string parameters

Returns

Psr\Http\Message\RequestInterface
public League\OAuth2\Client\Token\AccessToken
# getAccessToken( mixed $grant, array $options = [] )

Requests an access token using a specified grant and option set.

Requests an access token using a specified grant and option set.

Parameters

$grant
$options

Returns

League\OAuth2\Client\Token\AccessToken
public Psr\Http\Message\RequestInterface
# getRequest( string $method, string $url, array $options = [] )

Returns a PSR-7 request instance that is not authenticated.

Returns a PSR-7 request instance that is not authenticated.

Parameters

$method
$url
$options

Returns

Psr\Http\Message\RequestInterface
public Psr\Http\Message\RequestInterface
# getAuthenticatedRequest( string $method, string $url, League\OAuth2\Client\Token\AccessToken|string $token, array $options = [] )

Returns an authenticated PSR-7 request instance.

Returns an authenticated PSR-7 request instance.

Parameters

$method
$url
$token
$options
Any of "headers", "body", and "protocolVersion".

Returns

Psr\Http\Message\RequestInterface
protected Psr\Http\Message\RequestInterface
# createRequest( string $method, string $url, League\OAuth2\Client\Token\AccessToken|string|null $token, array $options )

Creates a PSR-7 request instance.

Creates a PSR-7 request instance.

Parameters

$method
$url
$token
$options

Returns

Psr\Http\Message\RequestInterface
public Psr\Http\Message\ResponseInterface
# getResponse( Psr\Http\Message\RequestInterface $request )

Sends a request instance and returns a response instance.

Sends a request instance and returns a response instance.

WARNING: This method does not attempt to catch exceptions caused by HTTP errors! It is recommended to wrap this method in a try/catch block.

Parameters

$request

Returns

Psr\Http\Message\ResponseInterface
public mixed
# getParsedResponse( Psr\Http\Message\RequestInterface $request )

Sends a request and returns the parsed response.

Sends a request and returns the parsed response.

Parameters

$request

Returns

mixed
protected array
# parseJson( string $content )

Attempts to parse a JSON response.

Attempts to parse a JSON response.

Parameters

$content
JSON content from response body

Returns

array
Parsed JSON data

Throws

UnexpectedValueException
if the content could not be parsed
protected string
# getContentType( Psr\Http\Message\ResponseInterface $response )

Returns the content type header of a response.

Returns the content type header of a response.

Parameters

$response

Returns

string
Semi-colon separated join of content-type headers.
protected array
# parseResponse( Psr\Http\Message\ResponseInterface $response )

Parses the response according to its content-type header.

Parses the response according to its content-type header.

Parameters

$response

Returns

array

Throws

UnexpectedValueException
abstract protected
# checkResponse( Psr\Http\Message\ResponseInterface $response, array|string $data )

Checks a provider response for errors.

Checks a provider response for errors.

Parameters

$response
$data
Parsed response data

Throws

League\OAuth2\Client\Provider\Exception\IdentityProviderException
protected array
# prepareAccessTokenResponse( array $result )

Prepares an parsed access token response for a grant.

Prepares an parsed access token response for a grant.

Custom mapping of expiration, etc should be done here. Always call the parent method when overloading this method.

Parameters

$result

Returns

array
protected League\OAuth2\Client\Token\AccessToken
# createAccessToken( array $response, League\OAuth2\Client\Grant\AbstractGrant $grant )

Creates an access token from a response.

Creates an access token from a response.

The grant that was used to fetch the response can be used to provide additional context.

Parameters

$response
$grant

Returns

League\OAuth2\Client\Token\AccessToken
abstract protected League\OAuth2\Client\Provider\ResourceOwnerInterface
# createResourceOwner( array $response, League\OAuth2\Client\Token\AccessToken $token )

Generates a resource owner object from a successful resource owner details request.

Generates a resource owner object from a successful resource owner details request.

Parameters

$response
$token

Returns

League\OAuth2\Client\Provider\ResourceOwnerInterface
public League\OAuth2\Client\Provider\ResourceOwnerInterface
# getResourceOwner( League\OAuth2\Client\Token\AccessToken $token )

Requests and returns the resource owner of given access token.

Requests and returns the resource owner of given access token.

Parameters

$token

Returns

League\OAuth2\Client\Provider\ResourceOwnerInterface
protected mixed
# fetchResourceOwnerDetails( League\OAuth2\Client\Token\AccessToken $token )

Requests resource owner details.

Requests resource owner details.

Parameters

$token

Returns

mixed
protected array
# getDefaultHeaders( )

Returns the default headers used by this provider.

Returns the default headers used by this provider.

Typically this is used to set 'Accept' or 'Content-Type' headers.

Returns

array
protected array
# getAuthorizationHeaders( mixed|null $token = null )

Returns the authorization headers used by this provider.

Returns the authorization headers used by this provider.

Typically this is "Bearer" or "MAC". For more information see: http://tools.ietf.org/html/rfc6749#section-7.1

No default is provided, providers must overload this method to activate authorization headers.

Parameters

$token
Either a string or an access token instance

Returns

array
public array
# getHeaders( mixed|null $token = null )

Returns all headers used by this provider for a request.

Returns all headers used by this provider for a request.

The request will be authenticated if an access token is provided.

Parameters

$token
object or string

Returns

array
Methods used from League\OAuth2\Client\Tool\QueryBuilderTrait
buildQueryString()
Constants summary
string ACCESS_TOKEN_RESOURCE_OWNER_ID
# null
string METHOD_GET
# 'GET'
string METHOD_POST
# 'POST'
Properties summary
protected string $clientId
#
protected string $clientSecret
#
protected string $redirectUri
#
protected string $state
#
protected League\OAuth2\Client\Grant\GrantFactory $grantFactory
#
protected League\OAuth2\Client\Tool\RequestFactory $requestFactory
#
protected GuzzleHttp\ClientInterface $httpClient
#
MercadoLibre Provider for OAuth 2.0 Client API documentation generated by ApiGen