title: Not authorized to request the scopes - Google OAuth2 for devices
body: <p>I've recently been working on accessing the gmail API from a python script.</p>
  
  <p>As the script needs to run on a server, without any form of web browser, I've had to implement the OAuth for Devices flow, as detailed at <a href="https://developers.google.com/accounts/docs/OAuth2ForDevices" rel="nofollow">https://developers.google.com/accounts/docs/OAuth2ForDevices</a></p>
  
  <p>This has gone just fine, as I've been testing with the "profile" scope, I've been getting access tokens as expected.</p>
  
  <p>However, to switch over to the the actual token that my script needs, as I need to be authorised to write to the user's email, I've tried running my script with the scope <code>www.googleapis.com/auth/gmail.compose</code>, which returns the following:</p>
  
  <pre><code>{u'error_uri': u'code.google.com/apis/accounts/docs/OAuth2.html', u'error_description': u'Not authorized to request the scopes: [www.googleapis.com/auth/gmail.compose]', u'error': u'invalid_scope'}
  </code></pre>
  
  <p>At this point I got curious, and tried a variety of scopes, it seems fairly arbitrary to me, which ones would, and would not work.</p>
  
  <p>Working:  </p>
  
  <pre><code>www.googleapis.com/auth/calendar
  www.google.com/m8/feeds
  </code></pre>
  
  <p>Not working:  </p>
  
  <pre><code>mail.google.com/
  www.googleapis.com/auth/gmail.compose
  www.googleapis.com/auth/gmail.readonly
  www.googleapis.com/auth/gmail.modify
  www.googleapis.com/auth/contacts.readonly
  </code></pre>
  
  <p>I've uploaded my code to <a href="https://gist.github.com/Hanse00/3a861430b1543599b3ed" rel="nofollow">https://gist.github.com/Hanse00/3a861430b1543599b3ed</a> for anyone interested in having a look.</p>
  
  <p>The Gmail API is indeed enabled in the project console.</p>
  
  <p>If anyone has any clue why this would be happening, I'd be glad to hear from you!</p>
  
  <p>Note: I've had to edit the scopes as they count as links, and my reputation is not high enough to post them all. The scopes I tried were in fact the correct ones.</p>