You are here

public function OAuthDrupalProvider::lookupConsumer in OAuth 1.0 8.2

Same name and namespace in other branches
  1. 8 src/Authentication/Provider/OAuthDrupalProvider.php \Drupal\oauth\Authentication\Provider\OAuthDrupalProvider::lookupConsumer()

Finds a user associated with the OAuth crendentials given in the request.

For the moment it handles two legged authentication for a pair of dummy key and secret, 'a' and 'b' respectively.

Parameters

\OAuthProvider $provider: An instance of OauthProvider with the authorization request headers.

Return value

int

  • OAUTH_OK if the authentication was successful.
  • OAUTH_CONSUMER_KEY_UNKNOWN if not.

See also

http://www.php.net/manual/en/class.oauthprovider.php

File

src/Authentication/Provider/OAuthDrupalProvider.php, line 121
Contains \Drupal\oauth\Authentication\Provider\OAuthProvider.

Class

OAuthDrupalProvider
Oauth authentication provider.

Namespace

Drupal\oauth\Authentication\Provider

Code

public function lookupConsumer(OAuthProvider $provider) {
  $user_data = $this->user_data
    ->get('oauth', NULL, $provider->consumer_key);
  if (!empty($user_data)) {
    $provider->consumer_secret = $user_data[key($user_data)]['consumer_secret'];
    $this->user = User::load(key($user_data));
    return OAUTH_OK;
  }
  else {
    return OAUTH_CONSUMER_KEY_UNKNOWN;
  }
}