You are here

public static function SimpleOauthAuthenticationProvider::hasTokenValue in Simple OAuth (OAuth2) & OpenID Connect 8.2

Gets the access token from the request.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request object.

Return value

bool TRUE if there is an access token. FALSE otherwise.

Overrides SimpleOauthAuthenticationProviderInterface::hasTokenValue

2 calls to SimpleOauthAuthenticationProvider::hasTokenValue()
DisallowSimpleOauthRequests::check in src/PageCache/DisallowSimpleOauthRequests.php
Determines whether delivery of a cached page should be attempted.
SimpleOauthAuthenticationProvider::applies in src/Authentication/Provider/SimpleOauthAuthenticationProvider.php
Checks whether suitable authentication credentials are on the request.

File

src/Authentication/Provider/SimpleOauthAuthenticationProvider.php, line 50

Class

SimpleOauthAuthenticationProvider
@internal

Namespace

Drupal\simple_oauth\Authentication\Provider

Code

public static function hasTokenValue(Request $request) {

  // Check the header. See: http://tools.ietf.org/html/rfc6750#section-2.1
  $auth_header = trim($request->headers
    ->get('Authorization', '', TRUE));
  return strpos($auth_header, 'Bearer ') !== FALSE;
}