Reputation: 23634
I'm using google-api-python-client and imapclient libraries to try get IMAP access to Gmail.
When going through the authentication flow, I'm getting "invalid scope" errors. I've tried both https://mail.google.com
and https://mail.google.com/mail/feed/atom
as scopes.
Here's what I'm trying to do:
from oauth2client.appengine import OAuth2Decorator
SCOPE = "https://mail.google.com"
# SCOPE = "https://mail.google.com/mail/feed/atom"
oauth2decorator_gmail = OAuth2Decorator(client_id="CLIENT_ID",
client_secret="CLIENT_SECRET",
scope=SCOPE,
callback_path='/mycallbackurl')
class AuthenticateSyncServices(webapp2.RequestHandler):
@oauth2decorator_gmail.oauth_required
def get(self):
self.response.write("Authenticated")
And here's the stacktrace:
INFO 2013-06-06 08:56:36,686 client.py:1304] Failed to retrieve access token: {
"error" : "invalid_scope"
}
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 1536, in __call__
rv = self.handle_exception(request, response, e)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 1530, in __call__
rv = self.router.dispatch(request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/util.py", line 68, in check_login
handler_method(self, *args)
File "/Users/John/Projects/my-app/backend/oauth2client/appengine.py", line 787, in get
credentials = decorator.flow.step2_exchange(self.request.params)
File "/Users/John/Projects/my-app/backend/oauth2client/util.py", line 128, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Users/John/Projects/my-app/backend/oauth2client/client.py", line 1310, in step2_exchange
raise FlowExchangeError(error_msg)
FlowExchangeError: invalid_scope
Upvotes: 0
Views: 1107
Reputation: 10985
From https://developers.google.com/gmail/xoauth2_protocol:
The scope for IMAP and SMTP access is https://mail.google.com/
Upvotes: 1