title: Using OAuth2 with username and password
body: <p>I have gained REST API acess to a certain service as part of a beta. I was told the authorization is throught OAuth2.</p>
  
  <p>I got the following:</p>
  
  <ol>
  <li>ID</li>
  <li>SECRET</li>
  <li>SITE</li>
  </ol>
  
  <p>I also got a code sample in Ruby:</p>
  
  <pre><code>client = OAuth2::Client.new(key, secret, :site =&gt; site) 
  token = client.password.get_token('your_email@mail.com', 'your_password') 
  access_token = OAuth2::AccessToken.new(client, token) 
  JSON.parse access_token.get("/v1/users/me").body rescue {} 
  </code></pre>
  
  <p>I'm trying to implement this same snippet in python with the <code>oauth2</code> package, without success:</p>
  
  <pre><code>consumer = oauth2.Consumer(key=self._client_id,
                             secret=self._client_secret)
  request_token_url = "api.theservice.com/"
  token = oauth2.Token(key=self._email, secret=self._password)
  client = oauth2.Client(consumer, token)
  resp, content = client.request(request_token_url, "GET")
  pprint.pprint(resp)
  pprint.pprint(content)
  resp, content = client.request(request_token_url + 'v1/users/me', "GET")
  pprint.pprint(resp)
  pprint.pprint(content)
  </code></pre>
  
  <p>The second response contains the following:</p>
  
  <pre><code>'www-authenticate': 'Bearer realm="Doorkeeper", error="invalid_token", '
                      'error_description="The access token is invalid"',
  </code></pre>
  
  <p>I also tried creating a <code>oauth2.Client</code> object without a token, and checked the first response for an <code>access_token</code>, but nothing of the sort came through.</p>
  
  <p>What is the proper way to authenticate here?</p>