You are here

protected function OAuth2DrupalAuthProvider::getInfoToken in OAuth2 Server 8

Same name and namespace in other branches
  1. 2.0.x src/Authentication/Provider/OAuth2DrupalAuthProvider.php \Drupal\oauth2_server\Authentication\Provider\OAuth2DrupalAuthProvider::getInfoToken()

Generates keys from "Authorization" request header field.

Parameters

string|null $authorization: The "Authorization" request header field.

string|null $key: Token / authentication_scheme.

Return value

array|false An array with the following keys:

  • authentication_scheme: (string) HTTP Authentication Scheme.
  • token: (string) $token.
1 call to OAuth2DrupalAuthProvider::getInfoToken()
OAuth2DrupalAuthProvider::authenticate in src/Authentication/Provider/OAuth2DrupalAuthProvider.php
Authenticates the user.

File

src/Authentication/Provider/OAuth2DrupalAuthProvider.php, line 234

Class

OAuth2DrupalAuthProvider
OAuth2 Drupal Auth Provider.

Namespace

Drupal\oauth2_server\Authentication\Provider

Code

protected function getInfoToken($authorization = NULL, $key = NULL) {
  if (empty($authorization)) {
    return FALSE;
  }
  @(list($authentication_scheme, $token) = explode(' ', $authorization, 2));
  if (empty($token)) {
    return FALSE;
  }
  $infoToken = [
    'authentication_scheme' => $authentication_scheme,
    'token' => $token,
  ];
  if (!empty($key) && array_key_exists($key, $infoToken)) {
    return $infoToken[$key];
  }
  else {
    return $infoToken;
  }
}