public function OAuthDrupalProvider::authenticate in OAuth 1.0 8
Same name and namespace in other branches
- 8.2 src/Authentication/Provider/OAuthDrupalProvider.php \Drupal\oauth\Authentication\Provider\OAuthDrupalProvider::authenticate()
Authenticates the user.
Parameters
\Symfony\Component\HttpFoundation\Request|null $request: The request object.
Return value
\Drupal\Core\Session\AccountInterface|null AccountInterface - in case of a successful authentication. NULL - in case where authentication failed.
Overrides AuthenticationProviderInterface::authenticate
File
- src/
Authentication/ Provider/ OAuthDrupalProvider.php, line 67 - Contains \Drupal\oauth\Authentication\Provider\OAuthProvider.
Class
- OAuthDrupalProvider
- Oauth authentication provider.
Namespace
Drupal\oauth\Authentication\ProviderCode
public function authenticate(Request $request) {
try {
// Initialize and configure the OauthProvider too handle the request.
$this->provider = new OAuthProvider();
$this->provider
->consumerHandler(array(
$this,
'lookupConsumer',
));
$this->provider
->timestampNonceHandler(array(
$this,
'timestampNonceChecker',
));
$this->provider
->tokenHandler(array(
$this,
'tokenHandler',
));
$this->provider
->is2LeggedEndpoint(TRUE);
// Now check the request validity.
$this->provider
->checkOAuthRequest();
} catch (OAuthException $e) {
// The OAuth extension throws an alert when there is something wrong
// with the request (ie. the consumer key is invalid).
$this->logger
->warning($e
->getMessage());
return NULL;
}
// Check if we found a user.
if (!empty($this->user)) {
return $this->user;
}
return NULL;
}