Clone Drupal Database abstraction layer logic for Oauth2.