server.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:Calendar-Analytics 作者: maheskett 项目源码 文件源码
def oauth2callback():
    """Authenticates google user and authorizes app"""

    logging.basicConfig(filename='debug.log', level=logging.WARNING)

    flow = flow_from_clientsecrets(
                  'client_secret.json',
                  scope='https://www.googleapis.com/auth/calendar.readonly \
                  https://www.googleapis.com/auth/plus.login',
                  redirect_uri=url_for('oauth2callback', _external=True))

    flow.params['access_type'] = 'online'
    flow.params['approval_prompt'] = 'auto'

    if 'code' not in request.args:
        auth_uri = flow.step1_get_authorize_url()
        return redirect(auth_uri)

    else:
        auth_code = request.args.get('code')
        credentials = flow.step2_exchange(auth_code)  # creates credentials object
        session['credentials'] = credentials.to_json()
        return redirect(url_for('oauth2'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号