diff --git a/oauth.install b/oauth.install
index 1227949..73fc4cd 100644
--- a/oauth.install
+++ b/oauth.install
@@ -26,57 +26,3 @@ function oauth_requirements($phase) {
 
   return $requirements;
 }
-
-/**
- * Implements hook_schema().
- */
-function oauth_schema() {
-  $schema = array();
-
-  $schema['oauth_consumer'] = array(
-    'description' => 'Keys and secrets for OAuth consumers, both those provided by this site and other sites.',
-    'fields' => array(
-      'cid' => array(
-        'type'        => 'serial',
-        'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
-        'not null'    => TRUE,
-      ),
-      'uid' => array(
-        'description' => 'The application owner.',
-        'type'        => 'int',
-        'unsigned'    => TRUE,
-        'not null'    => TRUE,
-      ),
-      'key_hash' => array(
-        'description' => 'SHA1-hash of consumer_key.',
-        'type'        => 'char',
-        'length'      => 40,
-        'not null'    => TRUE,
-      ),
-      // Key is a reserved word in MySQL so let's avoid that
-      'consumer_key' => array(
-        'description' => 'Consumer key.',
-        'type'        => 'text',
-        'not null'    => TRUE,
-      ),
-      'consumer_secret' => array(
-        'description' => 'Consumer secret.',
-        'type'        => 'text',
-        'not null'    => TRUE,
-      ),
-    ),
-    'primary key' => array('cid'),
-    'indexes' => array(
-      'key_hash' => array('key_hash'),
-      'uid' => array('uid'),
-    ),
-    'foreign keys' => array(
-      'users' => array(
-        'table' => 'users',
-        'columns' => array('uid' => 'uid'),
-      ),
-    ),
-  );
-
-  return $schema;
-}
diff --git a/oauth.module b/oauth.module
index 6b4d2ac..ef36a53 100644
--- a/oauth.module
+++ b/oauth.module
@@ -4,12 +4,3 @@
  * Hook implementations for OAuth module.
  */
 
-/**
- * Implements hook_user_delete().
- */
-function oauth_user_delete(Drupal\Core\Entity\EntityInterface $user) {
-  // Delete all consumers related to a user.
-  db_delete('oauth_consumer')
-    ->condition('uid', $user->id())
-    ->execute();
-}
diff --git a/oauth.routing.yml b/oauth.routing.yml
index 55bda22..314fa00 100644
--- a/oauth.routing.yml
+++ b/oauth.routing.yml
@@ -10,19 +10,20 @@ oauth.user_consumer:
   defaults:
     _controller: '\Drupal\oauth\Controller\OAuthController::consumers'
   requirements:
-    _permission: 'access own consumers'
+   _oauth_access_check: 'TRUE'
 
 oauth.user_consumer_add:
-  path: '/oauth/consumer/add'
+  path: '/oauth/consumer/add/{user}'
   defaults:
     _form: '\Drupal\oauth\Form\OAuthAddConsumerForm'
     _title: 'Add an OAuth Consumer'
   requirements:
-    _permission: 'access own consumers'
+    _oauth_access_check: 'TRUE'
+
 
 oauth.user_consumer_delete:
-  path: '/oauth/consumer/delete/{cid}'
+  path: '/oauth/consumer/delete/{user}/{key}'
   defaults:
     _form: '\Drupal\oauth\Form\OAuthDeleteConsumerForm'
   requirements:
-    _permission: 'access own consumers'
+    _oauth_access_check: 'TRUE'
diff --git a/oauth.services.yml b/oauth.services.yml
index 6253f6b..59ee1b3 100644
--- a/oauth.services.yml
+++ b/oauth.services.yml
@@ -1,10 +1,16 @@
 services:
   authentication.oauth:
     class: 'Drupal\oauth\Authentication\Provider\OAuthDrupalProvider'
-    arguments: ['@database', '@logger.channel.oauth']
+    arguments: ['@user.data', '@logger.channel.oauth']
     tags:
       - { name: 'authentication_provider', provider_id: oauth, priority: 100 }
 
   logger.channel.oauth:
     parent: 'logger.channel_base'
     arguments: ['oauth']
+
+  oauth.access_checker:
+      class: Drupal\oauth\Access\CustomAccessCheck
+      arguments: ['@current_user']
+      tags:
+        - { name: access_check, applies_to: _oauth_access_check }
diff --git a/src/Access/CustomAccessCheck.php b/src/Access/CustomAccessCheck.php
new file mode 100644
index 0000000..9481b61
--- /dev/null
+++ b/src/Access/CustomAccessCheck.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * @file
+ * Contains \Drupal\example\Access\CustomAccessCheck.
+ */
+
+namespace Drupal\oauth\Access;
+
+use Drupal\Core\Routing\Access\AccessInterface;
+use Drupal\Core\Session\AccountInterface;
+use Drupal\Core\Access\AccessResult;
+use Drupal\user\UserInterface;
+
+/**
+ * Checks access for oauth.
+ */
+class CustomAccessCheck implements AccessInterface {
+
+  /**
+   * Check if the user can administer their own keys, or has the 'administer
+   * consumer' permission.
+   *
+   * @param \Drupal\Core\User\UserInterface
+   * @param \Drupal\Core\Session\AccountInterface $account
+   *   Run access checks for this account.
+   * @return bool
+   */
+
+  public function access(UserInterface $user, AccountInterface $account) {
+    return AccessResult::allowedIfHasPermission($account, 'administer consumers')
+      ->orIf(
+        AccessResult::allowedIf($user->id() == $account->id())->addCacheableDependency($account)->
+        andIf(AccessResult::allowedIfHasPermission($account, 'access own consumers')));
+  }
+}
diff --git a/src/Authentication/Provider/OAuthDrupalProvider.php b/src/Authentication/Provider/OAuthDrupalProvider.php
index 0d92a5b..b705e9c 100644
--- a/src/Authentication/Provider/OAuthDrupalProvider.php
+++ b/src/Authentication/Provider/OAuthDrupalProvider.php
@@ -8,25 +8,25 @@
 namespace Drupal\oauth\Authentication\Provider;
 
 use Drupal\Core\Authentication\AuthenticationProviderInterface;
-use Drupal\Core\Database\Connection;
 use Drupal\user\Entity\User;
+use Drupal\user\UserDataInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
 use Psr\Log\LoggerInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
 use \OauthProvider;
 use \OauthException;
-
 /**
  * Oauth authentication provider.
  */
 class OAuthDrupalProvider implements AuthenticationProviderInterface {
 
  /**
-   * The database service.
+   * The user data service.
    *
-   * @var \Drupal\Core\Database\Connection
+   * @var \Drupal\user\UserDataInterface
    */
-  protected $connection;
+  protected $user_data;
 
   /**
    * The logger service for OAuth.
@@ -45,11 +45,13 @@ class OAuthDrupalProvider implements AuthenticationProviderInterface {
   /**
    * Constructor.
    *
+   * @param \Drupal\user\UserDataInterface
+   *  The user data service.
    * @param \Psr\Log\LoggerInterface $logger
    *   The logger service for OAuth.
    */
-  public function __construct(Connection $connection, LoggerInterface $logger) {
-    $this->connection = $connection;
+  public function __construct(UserDataInterface $user_data, LoggerInterface $logger) {
+    $this->user_data = $user_data;
     $this->logger = $logger;
   }
 
@@ -116,12 +118,13 @@ class OAuthDrupalProvider implements AuthenticationProviderInterface {
    * @see http://www.php.net/manual/en/class.oauthprovider.php
    */
   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;
+    $user_data = $this->user_data->get('oauth', NULL, $provider->consumer_key);
+    if (!empty($user_data)) {
+      foreach ($user_data as $uid => $consumer) {
+        $provider->consumer_secret = $consumer['consumer_secret'];
+        $this->user = User::load($uid);
+          return OAUTH_OK;
+      }
     }
     else {
       return OAUTH_CONSUMER_KEY_UNKNOWN;
diff --git a/src/Controller/OAuthController.php b/src/Controller/OAuthController.php
index fad4e14..dc89a27 100644
--- a/src/Controller/OAuthController.php
+++ b/src/Controller/OAuthController.php
@@ -11,10 +11,11 @@ use Drupal\Core\Controller\ControllerBase;
 use Drupal\Core\Database\Connection;
 use Drupal\Core\Url;
 use Drupal\Core\Utility\LinkGeneratorInterface;
+use Drupal\user\UserDataInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
 use Drupal\user\UserInterface;
-use Drupal\oauth\Form\OAuthDeleteConsumerForm;
+use Drupal\Core\Routing\RouteBuilderInterface;
 
 /**
  * Controller routines for oauth routes.
@@ -22,29 +23,30 @@ use Drupal\oauth\Form\OAuthDeleteConsumerForm;
 class OAuthController extends ControllerBase implements ContainerInjectionInterface {
 
   /**
-   * The database service.
+   * The URL generator service.
    *
-   * @var \Drupal\Core\Database\Connection
+   * @var \Drupal\Core\Utility\LinkGeneratorInterface
    */
-  protected $connection;
+  protected $linkGenerator;
 
   /**
-   * The URL generator service.
+   * The user data service.
    *
-   * @var \Drupal\Core\Utility\LinkGeneratorInterface
+   * @var \Drupal\user\UserData
    */
-  protected $linkGenerator;
+  protected $user_data;
 
   /**
    * Constructs an OauthController object.
    *
-   * @param \Drupal\Core\Database\Connection $connection
-   *   The database service.
+   * @param \Drupal\user\UserDataInterface $user_data
+   *   The user data service.
+   *
    * @param \Drupal\Core\Utility\LinkGeneratorInterface $link_generator
    *   The link generator service.
    */
-  public function __construct(Connection $connection, LinkGeneratorInterface $link_generator) {
-    $this->connection = $connection;
+  public function __construct(UserDataInterface $user_data, LinkGeneratorInterface $link_generator) {
+    $this->user_data = $user_data;
     $this->linkGenerator = $link_generator;
   }
 
@@ -52,13 +54,13 @@ class OAuthController extends ControllerBase implements ContainerInjectionInterf
    * {@inheritdoc}
    */
   public static function create(ContainerInterface $container) {
-    /** @var \Drupal\Core\Database\Connection $connection */
-    $connection = $container->get('database');
+    /** @var \Drupal\user\UserDataInterface $user_data */
+    $user_data = $container->get('user.data');
 
     /** @var \Drupal\Core\Utility\LinkGeneratorInterface $link_generator */
     $link_generator = $container->get('link_generator');
 
-    return new static($connection, $link_generator);
+    return new static($user_data, $link_generator);
   }
 
   /**
@@ -73,10 +75,14 @@ class OAuthController extends ControllerBase implements ContainerInjectionInterf
   public function consumers(UserInterface $user) {
     $list = array();
 
-    $list['heading']['#markup'] = $this->linkGenerator->generate($this->t('Add consumer'), Url::fromRoute('oauth.user_consumer_add'));
+    $list['#cache']['tags'] = array(
+      'oauth:' => $user->id(),
+    );
+
+    $list['heading']['#markup'] = $this->linkGenerator->generate($this->t('Add consumer'), Url::fromRoute('oauth.user_consumer_add', array('user' => $user->id())));
 
     // Get the list of consumers.
-    $result = $this->connection->query('select * from {oauth_consumer} where uid = :uid', array(':uid' => $user->id()));
+    $result = $this->user_data->get('oauth', $user->id());
 
     // Define table headers.
     $list['table'] = array(
@@ -96,18 +102,18 @@ class OAuthController extends ControllerBase implements ContainerInjectionInterf
     );
 
     // Add existing consumers to the table.
-    foreach ($result as $row) {
+    foreach ($result as $key => $consumer) {
       $list['table']['#rows'][] = array(
         'data' => array(
-          'consumer_key' => $row->consumer_key,
-          'consumer_secret' => $row->consumer_secret,
+          'consumer_key' => $key,
+          'consumer_secret' => $consumer['consumer_secret'],
           'operations' => array(
             'data' => array(
               '#type' => 'operations',
               '#links' => array(
                 'delete' => array(
                   'title' => $this->t('Delete'),
-                  'url' => Url::fromRoute('oauth.user_consumer_delete', array('cid' => $row->cid)),
+                  'url' => Url::fromRoute('oauth.user_consumer_delete', array('user' => $user->id(), 'key' => $key)),
                 ),
               ),
             ),
diff --git a/src/Form/OAuthAddConsumerForm.php b/src/Form/OAuthAddConsumerForm.php
index 38a3715..c0f6a29 100644
--- a/src/Form/OAuthAddConsumerForm.php
+++ b/src/Form/OAuthAddConsumerForm.php
@@ -7,10 +7,12 @@
 
 namespace Drupal\oauth\Form;
 
-use Drupal\Core\Database\Connection;
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\Session\AccountProxyInterface;
+use Drupal\user\UserDataInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -28,23 +30,23 @@ class OAuthAddConsumerForm extends FormBase {
   protected $account;
 
   /**
-   * The database service.
+   * The user data service.
    *
-   * @var \Drupal\Core\Database\Connection
+   * @var \Drupal\user\UserData
    */
-  protected $connection;
+  protected $user_data;
 
   /**
    * {@inheritdoc}
    */
   public static function create(ContainerInterface $container) {
-    /** @var \Drupal\Core\Database\Connection $connection */
-    $connection = $container->get('database');
 
     /** @var \Drupal\Core\Session\AccountProxyInterface $current_user */
     $current_user = $container->get('current_user');
 
-    return new static($connection, $current_user);
+    /** @var \Drupal\user\UserDataInterface $user_data */
+    $user_data = $container->get('user.data');
+    return new static($current_user, $user_data);
   }
 
   /**
@@ -56,24 +58,29 @@ class OAuthAddConsumerForm extends FormBase {
 
   /**
    * {@inheritdoc}
-   * @param \Drupal\Core\Database\Connection $connection
-   *   The database service.
    * @param \Drupal\Core\Session\AccountProxyInterface $account
    *   The current user service.
+   * @param \Drupal\user\UserDataInterface $user_data
+   *  The user data service.
    */
-  public function __construct(Connection $connection, AccountProxyInterface $account) {
-    $this->connection = $connection;
+  public function __construct(AccountProxyInterface $account, UserDataInterface $user_data) {
     $this->account = $account;
+    $this->user_data = $user_data;
   }
 
   /**
    * {@inheritdoc}
    */
-  public function buildForm(array $form, FormStateInterface $form_state) {
+  public function buildForm(array $form, FormStateInterface $form_state, AccountInterface $user = NULL) {
+
     $form['save'] = array(
       '#type' => 'submit',
       '#value' => $this->t('Add'),
     );
+    $form['uid'] = array(
+      '#type' => 'hidden',
+      '#value' => $user->id(),
+    );
 
     return $form;
   }
@@ -85,17 +92,15 @@ class OAuthAddConsumerForm extends FormBase {
     $consumer_key = user_password(32);
     $consumer_secret  = user_password(32);
     $key_hash = sha1($consumer_key);
-    $this->connection->insert('oauth_consumer')
-      ->fields(array(
-        'uid' => $this->account->id(),
-        'consumer_key' => $consumer_key,
-        'consumer_secret' => $consumer_secret,
-        'key_hash' => $key_hash,
-      ))
-      ->execute();
-
+    $uid = $form_state->getValue('uid');
+    $consumer = array(
+      'consumer_secret' => $consumer_secret,
+      'key_hash' => $key_hash,
+    );
+    $this->user_data->set('oauth', $uid, $consumer_key, $consumer);
     drupal_set_message($this->t('Added a new consumer.'));
-    $form_state->setRedirect('oauth.user_consumer', array('user' => \Drupal::currentUser()->id()));
+    Cache::invalidateTags(['oauth:' . $uid]);
+    $form_state->setRedirect('oauth.user_consumer', array('user' => $uid));
   }
 
 }
diff --git a/src/Form/OAuthDeleteConsumerForm.php b/src/Form/OAuthDeleteConsumerForm.php
index 637ad01..abe4166 100644
--- a/src/Form/OAuthDeleteConsumerForm.php
+++ b/src/Form/OAuthDeleteConsumerForm.php
@@ -7,11 +7,14 @@
 
 namespace Drupal\oauth\Form;
 
-use Drupal\Core\Database\Connection;
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Form\ConfirmFormBase;
 use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Url;
+use Drupal\Core\Session\AccountInterface;
+use Drupal\Core\Session\AccountProxyInterface;
+use Drupal\user\UserDataInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -22,6 +25,20 @@ class OAuthDeleteConsumerForm extends ConfirmFormBase implements ContainerInject
   const NAME = 'oauth_delete_consumer_form';
 
   /**
+   * The current user service.
+   *
+   * @var \Drupal\Core\Session\AccountProxyInterface
+   */
+  protected $account;
+
+  /**
+   * The user data service.
+   *
+   * @var \Drupal\user\UserData
+   */
+  protected $user_data;
+
+  /**
    * Factory.
    *
    * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
@@ -31,19 +48,26 @@ class OAuthDeleteConsumerForm extends ConfirmFormBase implements ContainerInject
    *   The form instance.
    */
   public static function create(ContainerInterface $container) {
-    /** @var \Drupal\Core\Database\Connection $database */
-    $database = $container->get('database');
-    return new static($database);
+
+    /** @var \Drupal\Core\Session\AccountProxyInterface $current_user */
+    $current_user = $container->get('current_user');
+
+    /** @var \Drupal\user\UserDataInterface $user_data */
+    $user_data = $container->get('user.data');
+
+    return new static($current_user, $user_data);
   }
 
   /**
    * Constructor.
    *
-   * @param \Drupal\Core\Database\Connection $connection
-   *   The database service.
+   * @param \Drupal\Core\Session\AccountProxyInterface
+   *
+   * @param \Drupal\user\UserDataInterface
    */
-  public function __construct(Connection $connection) {
-    $this->connection = $connection;
+  public function __construct(AccountProxyInterface $account, UserDataInterface $user_data) {
+    $this->account = $account;
+    $this->user_data = $user_data;
   }
 
   /**
@@ -98,10 +122,15 @@ class OAuthDeleteConsumerForm extends ConfirmFormBase implements ContainerInject
   /**
    * {@inheritdoc}
    */
-  public function buildForm(array $form, FormStateInterface $form_state, $cid = NULL) {
-    $form['cid'] = array(
+  public function buildForm(array $form, FormStateInterface $form_state, AccountInterface $user = NULL, $key = NULL) {
+    $form['key'] = array(
+      '#type' => 'hidden',
+      '#value' => $key,
+    );
+
+    $form['uid'] = array(
       '#type' => 'hidden',
-      '#value' => $cid,
+      '#value' => $user->id()
     );
 
     $form = parent::buildForm($form, $form_state);
@@ -114,12 +143,12 @@ class OAuthDeleteConsumerForm extends ConfirmFormBase implements ContainerInject
    */
   public function submitForm(array &$form, FormStateInterface $form_state) {
     $values = $form_state->getValues();
-    $cid = $values['cid'];
-    $this->connection->delete('oauth_consumer')
-      ->condition('cid', $cid)
-      ->execute();
+    $key = $values['key'];
+    $uid = $values['uid'];
+    $this->user_data->delete('oauth', $uid, $key);
     drupal_set_message($this->t('OAuth consumer deleted.'));
-    $form_state->setRedirect('oauth.user_consumer', ['user' => \Drupal::currentUser()->id()]);
+    Cache::invalidateTags(['oauth:' . $uid]);
+    $form_state->setRedirect('oauth.user_consumer', array('user' => $form_state->getValue('uid')));
   }
 
 }
diff --git a/src/Tests/OAuthTest.php b/src/Tests/OAuthTest.php
index 066d973..50dfbac 100644
--- a/src/Tests/OAuthTest.php
+++ b/src/Tests/OAuthTest.php
@@ -7,6 +7,7 @@
 namespace Drupal\oauth\Tests;
 
 use Drupal\simpletest\WebTestBase;
+use Drupal\user\USerData;
 
 /**
  * Tests oauth functionality.
@@ -38,12 +39,34 @@ class OAuthTest extends WebTestBase {
     $this->assertResponse(200);
 
     // Generate a set of consumer keys.
-    $this->drupalPostForm('oauth/consumer/add', array(), 'Add');
+    $this->drupalPostForm('oauth/consumer/add/' . $account->id(), array(), 'Add');
     $this->assertText(t('Added a new consumer.'));
 
     // Delete the set of consumer keys.
-    $consumer = db_query('select * from {oauth_consumer} where uid = :uid', array(':uid' => $account->id()))->fetchObject();
-    $this->drupalPostForm('oauth/consumer/delete/' . $consumer->cid, array(), 'Delete');
+    $user_data = \Drupal::service('user.data')->get('oauth', $account->id());
+    foreach ($user_data as $key => $consumer) {
+      $this->drupalPostForm('oauth/consumer/delete/' . $account->id() . '/' . $key, array(), 'Delete');
+    }
+    $this->assertText(t('OAuth consumer deleted.'));
+
+    $this->drupalLogout();
+
+    // Test administer consumer permissions
+    $admin_account = $this->drupalCreateUser(array('administer consumers'));
+    $this->drupalLogin($admin_account);
+
+    $this->drupalGet('user/' . $account->id() . '/oauth/consumer');
+    $this->assertResponse(200);
+
+    // Generate a set of consumer keys.
+    $this->drupalPostForm('oauth/consumer/add/' . $account->id(), array(), 'Add');
+    $this->assertText(t('Added a new consumer.'));
+
+    // Delete the set of consumer keys.
+    $user_data = \Drupal::service('user.data')->get('oauth', $account->id());
+    foreach ($user_data as $key => $consumer) {
+      $this->drupalPostForm('oauth/consumer/delete/' . $account->id() . '/' . $key, array(), 'Delete');
+    }
     $this->assertText(t('OAuth consumer deleted.'));
 
     $this->drupalLogout();
@@ -90,25 +113,27 @@ class OAuthTest extends WebTestBase {
     $this->drupalLogin($account);
 
     // Generate a set of consumer keys.
-    $this->drupalPostForm('oauth/consumer/add', array(), 'Add');
-    $consumer = db_query('select * from {oauth_consumer} where uid = :uid', array(':uid' => $account->id()))->fetchObject();
-
-    // Now send an authenticated request to read the entity through REST.
-    $url = $entity->urlInfo()->setRouteParameter('_format', $format);
-    $endpoint = $url->setAbsolute()->toString();
-    $oauth = new \OAuth($consumer->consumer_key, $consumer->consumer_secret);
-    $oauth_header = $oauth->getRequestHeader('GET', $endpoint);
-    $out = $this->curlExec(
-      array(
-        CURLOPT_HTTPGET => TRUE,
-        CURLOPT_NOBODY => FALSE,
-        CURLOPT_URL => $endpoint,
-        CURLOPT_HTTPHEADER => array('Authorization: ' . $oauth_header),
-      )
-    );
-    $this->verbose('GET request to: ' . $endpoint . '<hr />' . $out);
-    $this->assertResponse('200', 'HTTP response code is 200 for successfully authenticated request.');
-    $this->curlClose();
+    $this->drupalPostForm('oauth/consumer/add/' . $account->id(), array(), 'Add');
+    // Get the consumer we just generated for the new user.
+    $user_data = \Drupal::service('user.data')->get('oauth', $account->id());
+    foreach ($user_data as $key => $consumer) {
+      // Now send an authenticated request to read the entity through REST.
+      $url = $entity->urlInfo()->setRouteParameter('_format', $format);
+      $endpoint = $url->setAbsolute()->toString();
+      $oauth = new \OAuth($key, $consumer['consumer_secret']);
+      $oauth_header = $oauth->getRequestHeader('GET', $endpoint);
+      $out = $this->curlExec(
+        array(
+          CURLOPT_HTTPGET => TRUE,
+          CURLOPT_NOBODY => FALSE,
+          CURLOPT_URL => $endpoint,
+          CURLOPT_HTTPHEADER => array('Authorization: ' . $oauth_header),
+        )
+      );
+      $this->verbose('GET request to: ' . $endpoint . '<hr />' . $out);
+      $this->assertResponse('200', 'HTTP response code is 200 for successfully authenticated request.');
+      $this->curlClose();
+    };
   }
 
   /**
@@ -123,13 +148,13 @@ class OAuthTest extends WebTestBase {
     $this->drupalLogin($account);
 
     // Generate a set of consumer keys.
-    $this->drupalPostForm('oauth/consumer/add', array(), 'Add');
+    $this->drupalPostForm('oauth/consumer/add/' . $account->id(), array(), 'Add');
 
     // Delete the user.
     $uid = $account->id();
     $account->delete();
     // Check that its consumers were deleted.
-    $consumer = db_query('select cid FROM {oauth_consumer} WHERE uid = :uid', array(':uid' => $uid))->fetchField();
+    $consumer = \Drupal::service('user.data')->get('oauth', $uid);
     $this->assertFalse($consumer, t('Consumer keys were deleted on user deletion.'));
   }
 
