के साथ OAuth का उपयोग करने वाली उपयोगकर्ता जानकारी OAuth 2.0 और पायथन का उपयोग करते समय मैं उपयोगकर्ता आईडी या ईमेल को OAuth एक्सेस टोकन को स्टोर/पुनर्प्राप्त करना चाहता हूं क्योंकि मैं उपयोगकर्ता के जाने के बाद भी कैलेंडर को संशोधित करना चाहता हूं।Google ऐप इंजन
बहुत सारे दस्तावेज हैं और इसमें से आधा बहिष्कृत है (ओएथ 1.0) कि मैं इसे समझने में सक्षम नहीं हूं।
मैं निम्नलिखित कोड है:
import webapp2
import os
from apiclient.discovery import build
from oauth2client.appengine import OAuth2DecoratorFromClientSecrets
from google.appengine.api import oauth
user_scope = 'https://www.googleapis.com/auth/userinfo.profile'
decorator = OAuth2DecoratorFromClientSecrets(
os.path.join(os.path.dirname(__file__), 'client_secrets.json'),
scope=('https://www.googleapis.com/auth/calendar', user_scope)
)
service = build('calendar', 'v3')
class MainHandler(webapp2.RequestHandler):
@decorator.oauth_required
def get(self):
self.response.write('Hello world!')
user = oauth.get_current_user(user_scope)
if user:
self.response.write('%s\n' % user)
self.response.write('- email = %s\n' % user.email())
self.response.write('- nickname = %s\n' % user.nickname())
self.response.write('- user_id = %s\n' % user.user_id())
else:
self.response.write('No user found...')
app = webapp2.WSGIApplication([
('/', MainHandler),
(decorator.callback_path, decorator.callback_handler())
], debug=True)
यह परीक्षण परिवेश में स्थानीय स्तर पर काम करता है, लेकिन जब मैं इसे तैनात है और यह ऑनलाइन चलाने मैं मिल निम्न त्रुटि:
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/base/data/home/apps/s~myapp/oauth2client/appengine.py", line 714, in check_oauth
resp = method(request_handler, *args, **kwargs)
File "/base/data/home/apps/s~myapp/main.py", line 29, in get
user = oauth.get_current_user('https://www.googleapis.com/auth/userinfo.profile')
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/oauth/oauth_api.py", line 100, in get_current_user
_maybe_call_get_oauth_user(_scope)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/oauth/oauth_api.py", line 231, in _maybe_call_get_oauth_user
_maybe_raise_exception()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/oauth/oauth_api.py", line 246, in _maybe_raise_exception
raise NotAllowedError(error_detail)
NotAllowedError
क्या मैं कर रहा हूँ गायब है कि इस त्रुटि का कारण बनता है?
शायद यह Google libs में http tracing को सक्षम करने के लायक है ताकि आप देख सकें कि तार पर क्या चल रहा है। OAuth libs अंतर्निहित त्रुटि को खराब करने की तरह है। मेरा अनुमान होगा कि आपका कॉलबैक यूआरएल गलत है। – pinoyyid
+1 के लिए 'कोई दस्तावेज नहीं है लेकिन [यह सब बकवास है] '। यह वास्तव में कोई दस्तावेज की सामान्य शिकायत पर एक विपरीत है। यहां आपको आवश्यक जानकारी की गड़बड़ी खोजने के लिए सुई-इन-हैस्टैक है। –