diff --git a/restws_oauth/README.txt b/restws_oauth/README.txt
new file mode 100644
index 0000000..e6bb7af
--- /dev/null
+++ b/restws_oauth/README.txt
@@ -0,0 +1,15 @@
+--------------------------------------------------------------------------------
+                    Simple OAuth for RESTful Web Services
+--------------------------------------------------------------------------------
+
+This module uses the OAuth module to perform an user login, using the uid of
+the consumer or token. Currently authentications levels ignored, and the client
+will have therefore the all permissions of the user.
+
+Per default the context restws will be used together with a 3-legged Oauth. You
+can change this settings under /admin/config/services/restws_oauth.
+To test the module I recommend a OAuth capable client like the firefox plugin
+RestClient (https://addons.mozilla.org/de/firefox/addon/restclient/).
+You also will need a client to perform the authorization, one possibillity is
+to use this python lib https://github.com/simplegeo/python-oauth2/, with the
+examples given in the Readme.
diff --git a/restws_oauth/restws_oauth.info b/restws_oauth/restws_oauth.info
new file mode 100644
index 0000000..e0f2aac
--- /dev/null
+++ b/restws_oauth/restws_oauth.info
@@ -0,0 +1,4 @@
+name = RestWS OAuth
+description = User login from HTTP authorization headers.
+core = 7.x
+dependencies[] = oauth_common
diff --git a/restws_oauth/restws_oauth.module b/restws_oauth/restws_oauth.module
new file mode 100644
index 0000000..ed80391
--- /dev/null
+++ b/restws_oauth/restws_oauth.module
@@ -0,0 +1,142 @@
+<?php
+
+/**
+ * @file
+ * Simple OAuth login - module file.
+ */
+
+/**
+ * Implements hook_permission().
+ */
+function restws_oauth_common_permission() {
+  return array(
+    'administer restws oauth' => array(
+      'title' => t('Administer RestWS OAuth'),
+      'restrict access' => TRUE,
+    ),
+  );
+}
+
+/**
+ * Implements hook_menu().
+ */
+function restws_oauth_menu() {
+  $items['admin/config/services/restws_oauth'] = array(
+    'title' => 'RestWS OAuth',
+    'description' => 'Settings for RestWS OAuth',
+    'page callback' => 'drupal_get_form',
+    'type' => MENU_NORMAL_ITEM,
+    'access arguments' => array('administer restws oauth'),
+    'page arguments' => array('restws_oauth_admin'),
+  );
+  return $items;
+}
+
+/**
+ * Administration form.
+ */
+function restws_oauth_admin($form, &$form_state) {
+  $contexts = oauth_common_context_load_all();
+  $context_options = array();
+
+  foreach ($contexts as $name => $context) {
+    $context_options[$name] = $context->title;
+  }
+
+  if (empty($context_options)) {
+    // todo: show a link to create new context.
+  }
+
+  $form['context'] = array(
+    '#type' => 'radios',
+    '#title' => t('Authentication mode'),
+    '#default_value' => variable_get('restws_oauth_context', ''),
+    '#type'          => 'select',
+    '#options'       => $context_options,
+    '#description'   => t('The context that should be used.'),
+  );
+
+  $form['mode'] = array(
+    '#type' => 'radios',
+    '#title' => t('Authentication mode'),
+    '#default_value' => variable_get('restws_oauth_mode', 'token'),
+    '#type'          => 'select',
+    '#options'       => array(
+      'consumer'          => t('Consumer key, also known as 2-legged OAuth'),
+      'token'             => t('Consumer key and access token, also known as 3-legged OAuth'),
+    ),
+    '#description'   => t('The authentication type required for a succesfull login.'),
+  );
+
+  $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
+
+  return $form;
+}
+
+/**
+ * Submit function for the administration form.
+ */
+function restws_oauth_admin_submit(&$form, &$form_state) {
+  variable_set('restws_oauth_context', $form_state['values']['context']);
+  variable_set('restws_oauth_mode', $form_state['values']['mode']);
+  drupal_set_message("You're settings have been saved.");
+}
+
+/**
+ * Implements hook_init().
+ *
+ * Logs a user in, if the OAuth credentials are valid.
+ */
+function restws_oauth_init() {
+  $auth_mode = variable_get('restws_oauth_mode', 'token');
+  $context = variable_get('restws_oauth_context', 'restws');
+  try {
+    module_load_include('inc', 'oauth_common');
+
+    list($signed, $consumer, $token) = oauth_common_verify_request();
+
+    // Cancel authentication, it isn't signed, since we don't support that case.
+    if (!$signed) {
+      throw new OAuthException('The request must be signed');
+    }
+    if ($consumer == NULL) {
+      throw new OAuthException('Missing consumer token');
+    }
+    if ($consumer->context !== $context) {
+      throw new OAuthException('The consumer is not valid in the current context');
+    }
+
+    // Validate the token, if it's required by the method.
+    if ($auth_mode == 'token') {
+      if (empty($token->key)) {
+        throw new OAuthException('Missing access token');
+      }
+      if (!$token->authorized) {
+        throw new OAuthException('The access token is not authorized');
+      }
+    }
+
+    // Load the user if the request was authenticated using a token
+    // that's associated with a account.
+    if ($auth_mode == 'token') {
+      if ($token->uid) {
+        global $user;
+        $user = user_load($token->uid);
+        drupal_static_reset();
+      }
+    }
+    elseif ($auth_mode == 'consumer') {
+      if ($consumer->uid) {
+        // This authenticates as the user who owns 'key';  It is for 2-stage
+        // OAuth and is vastly inferior to 3-stage OAuth.
+        global $user;
+        $user = user_load($consumer->uid);
+        drupal_static_reset();
+      }
+    }
+
+  }
+  catch (OAuthException $e) {
+    // Do nothing since we don't know if this is a normal or a restws request.
+  }
+}
