views.py 文件源码

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

项目:oscars2016 作者: 0x0ece 项目源码 文件源码
def oauth2_authorize(request):
    """ View to start the OAuth2 Authorization flow

     This view starts the OAuth2 authorization flow. If scopes is passed in
     as a  GET URL parameter, it will authorize those scopes, otherwise the
     default scopes specified in settings. The return_url can also be
     specified as a GET parameter, otherwise the referer header will be
     checked, and if that isn't found it will return to the root path.

    :param request: The Django request object
    :return: A redirect to Google OAuth2 Authorization
    """
    scopes = request.GET.getlist('scopes', django_util.oauth2_settings.scopes)
    return_url = request.GET.get('return_url', None)

    if not return_url:
        return_url = request.META.get('HTTP_REFERER', '/')
    flow = _make_flow(request=request, scopes=scopes, return_url=return_url)
    auth_url = flow.step1_get_authorize_url()
    return shortcuts.redirect(auth_url)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号