我已成功在Google App Engine上創建了一個與Gmail API交互的python web-app。我現在想得到的是,當給出權限時,我的應用程序還會創建一個用戶帳戶,用戶可以使用他們的Google帳戶登錄。這將阻止用戶不得不爲我的應用輸入另一個密碼。向GMail API授權添加單點登錄
總之,目前的工作流程是: 1.用戶通過電子郵件和密碼輸入創建帳戶 2.用戶授權Gmail的存取
我想獲得的是:1。 用戶連接谷歌帳戶和隨即獲得一個帳戶並驗證GMail訪問
這樣做的最佳方法是什麼?
我目前的google API代碼如下所示。直接從谷歌這裏的例子:https://developers.google.com/api-client-library/python/guide/google_app_engine
from apiclient.discovery import build
from google.appengine.ext import webapp
from oauth2client.appengine import OAuth2Decorator
decorator = OAuth2Decorator(
client_id='your_client_id',
client_secret='your_client_secret',
scope='https://www.googleapis.com/auth/calendar')
service = build('calendar', 'v3')
class MainHandler(webapp.RequestHandler):
@decorator.oauth_required
def get(self):
# Get the authorized Http object created by the decorator.
http = decorator.http()
# Call the service using the authorized Http object.
request = service.events().list(calendarId='primary')
response = request.execute(http=http)