You are here

public function OauthToken::obtainAccess in Commerce Square Connect 8

Controller access method.

Return value

\Drupal\Core\Access\AccessResult The access result.

1 string reference to 'OauthToken::obtainAccess'
commerce_square.routing.yml in ./commerce_square.routing.yml
commerce_square.routing.yml

File

src/Controller/OauthToken.php, line 41

Class

OauthToken
Provides a controller for Square access token retrieval via OAuth.

Namespace

Drupal\commerce_square\Controller

Code

public function obtainAccess() {

  // $request is not passed in to _custom_access.
  // @see https://www.drupal.org/node/2786941
  if (\Drupal::csrfToken()
    ->validate(\Drupal::request()->query
    ->get('state'))) {
    return AccessResult::allowed();
  }
  return AccessResult::forbidden('Could not validate state in OAuth validation handshake.');
}