diff --git a/wsclient_rest/wsclient_rest.module b/wsclient_rest/wsclient_rest.module
index e52e6cb..0d6adc9 100644
--- a/wsclient_rest/wsclient_rest.module
+++ b/wsclient_rest/wsclient_rest.module
@@ -41,15 +41,18 @@ class WSClientRESTEndpoint extends WSClientEndpoint {
       $authentication = NULL;
       if (isset($this->service->settings['authentication'])) {
         // Handle each type of authentication.
-        foreach ($this->service->settings['authentication'] as $auth) {
+        foreach ($this->service->settings['authentication'] as $auth => $auth_settings) {
           // @todo Allow multiple authentications by implementing and using HttpClientCompositeAuth.
           switch ($auth) {
             case 'basic':
             default:
-              $username = $this->service->settings['authentication']['basic']['username'];
-              $password = $this->service->settings['authentication']['basic']['password'];
+              $username = $auth_settings['username'];
+              $password = $auth_settings['password'];
               $authentication = new HttpClientBasicAuth($username, $password);
               break;
+            case 'oauth2':
+              $authentication = new HttpClientOAuth2($auth_settings);
+              break;
           }
         }
       }
