You are here

public function OAuthDrupalProvider::lookupConsumer in OAuth 1.0 8

Same name and namespace in other branches
  1. 8.2 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 118
Contains \Drupal\oauth\Authentication\Provider\OAuthProvider.

Class

OAuthDrupalProvider
Oauth authentication provider.

Namespace

Drupal\oauth\Authentication\Provider

Code

public function lookupConsumer(OAuthProvider $provider) {
  $row = $this->connection
    ->query('select * from {oauth_consumer} where consumer_key = :consumer_key', array(
    ':consumer_key' => $provider->consumer_key,
  ))
    ->fetchObject();
  if (!empty($row)) {
    $provider->consumer_secret = $row->consumer_secret;
    $this->user = User::load($row->uid);
    return OAUTH_OK;
  }
  else {
    return OAUTH_CONSUMER_KEY_UNKNOWN;
  }
}