Ejemplo n.º 1
0
 def get(self, request):
     # 获取登录成功后的跳转连接
     next = request.GET.get('next')
     if next is None:
         next = '/'
     # 1、初始化创建qq对象
     qq = OAuthQQ(client_id=settings.QQ_CLIENT_ID, client_secret=settings.QQ_CLIENT_SECRET,
                  redirect_uri=settings.QQ_REDIRECT_URI, state=next)
     # 2、调用方法生成跳转连接
     login_url = qq.get_qq_url()
     # 3、返回跳转连接
     return JsonResponse({'login_url': login_url})
Ejemplo n.º 2
0
    def get(self, request):
        # next表示从哪个页面进入到的登录页面,将来登录成功后,就自动回到那个页面
        next = request.query_params.get('next')
        if not next:
            next = '/'

        # 获取QQ登录页面网址
        oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID, client_secret=settings.QQ_CLIENT_SECRET,
                        redirect_uri=settings.QQ_REDIRECT_URI, state=next)
        login_url = oauth.get_qq_url()

        return Response({'login_url': login_url})
Ejemplo n.º 3
0
 def get(self, request):
     next = request.GET.get('next')
     oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                     client_secret=settings.QQ_CLIENT_SECRET,
                     redirect_uri=settings.QQ_REDIRECT_URI,
                     state=next)
     login_url = oauth.get_qq_url()
     return JsonResponse({
         'code': 0,
         'errmsg': 'OK',
         'login_url': login_url
     })
Ejemplo n.º 4
0
 def get(self, request):
     # 获取state
     state = request.query_params.get('state', '/')
     # QQ对象
     qq = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                  client_secret=settings.QQ_CLIENT_SECRET,
                  redirect_uri=settings.QQ_REDIRECT_URI,
                  state=state)
     # 调用QQ对象生成跳转连接
     login_url = qq.get_qq_url()
     # 返回跳转链接
     return Response({"login_url": login_url})
Ejemplo n.º 5
0
 def get(self, request):
     #1 创建qq对象
     oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                     client_secret=settings.QQ_CLIENT_SECRET,
                     redirect_uri=settings.QQ_REDIRECT_URI,
                     state='next')
     #
     # #2 获取登录界面
     login_url = oauth.get_qq_url()
     #
     # #3 返回页面
     return http.JsonResponse({'errmsg': 'OK', 'login_url': login_url})
Ejemplo n.º 6
0
 def get(self, request):
     next = request.GET.get("next", "/")
     oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                     client_secret=settings.QQ_CLIENT_SECRET,
                     redirect_uri=settings.QQ_REDIRECT_URI,
                     state=next)
     login_url = oauth.get_qq_url()
     return JsonResponse({
         "code": 0,
         "message": "OK",
         "login_url": login_url
     })
Ejemplo n.º 7
0
    def get(self, request):

        qq = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                     client_secret=settings.QQ_CLIENT_SECRET,
                     redirect_uri=settings.QQ_REDIRECT_URI,
                     state='xxxxx')
        qq_login_url = qq.get_qq_url()
        return JsonResponse({
            'code': 0,
            'errmsg': 'ok',
            'login_url': qq_login_url
        })
Ejemplo n.º 8
0
    def get(self, request):
        next = request.query_params.get('next')
        if not next:
            next = '/'  # 这种操作有什么用?

        # 初始化
        oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                        client_secret=settings.QQ_CLIENT_SECRET,
                        redirect_uri=settings.QQ_REDIRECT_URI,
                        state=next)
        login_url = oauth.get_qq_url()

        return Response({'login_url': login_url})
Ejemplo n.º 9
0
Archivo: views.py Proyecto: sunsyw/web
    def get(self, request):
        state = request.query_params.get('state')
        if not state:
            state = '/'

        # 获取qq登录网址
        oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                        client_secret=settings.QQ_CLIENT_SECRET,
                        redirect_uri=settings.QQ_REDIRECT_URI,
                        state=state)
        auth_url = oauth.get_qq_url()

        return Response({'auth_url': auth_url})
Ejemplo n.º 10
0
 def get(self, request):
     #获取查询字符串内容
     state = request.query_params.get('next')
     if not state:
         state = '/'
     #调用接口
     qq = OAuthQQ(client_id=dev.QQ_CLIENT_ID,
                  client_secret=settings.QQ_CLIENT_SECRET,
                  redirect_uri=dev.QQ_REDIRECT_URI,
                  state=state)
     #获取跳转页面
     login_url = qq.get_qq_url()
     return Response({'login_url': login_url})
Ejemplo n.º 11
0
    def get(self, request):
        # next表示从哪个页面进入到的登录页面,将来登录成功后就自动回到那个页面
        next = request.query_params.get("next")
        if not next:
            next = "/"  # 首页

        oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                        client_secret=settings.QQ_CLIENT_SECRET,
                        redirect_uri=settings.QQ_REDIRECT_URI,
                        state=next)

        login_url = oauth.get_qq_url()
        return Response({"login_url": login_url})
Ejemplo n.º 12
0
    def get(self, request):
        #1,获取参数
        state = request.GET.get("next", "/")
        #2.创建OAuthQQ对象
        oauth_qq = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                           client_secret=settings.QQ_CLIENT_SECRET,
                           redirect_uri=settings.QQ_REDIRECT_URI,
                           state=next)

        #获取qq登陆页面
        login_url = oauth_qq.get_qq_url()
        #返回
        return http.JsonResponse({"login_url": login_url})
Ejemplo n.º 13
0
 def get(self, request):
     # 获取url位置参数:next
     next = request.query_params.get("next")
     if not next:
         next = '/'
     # 创建OAuthQQ对象
     auth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                    client_secret=settings.QQ_CLIENT_SECRET,
                    redirect_uri=settings.QQ_REDIRECT_URI,
                    state=next)
     # 获取登录url
     login_url = auth.get_qq_url()
     return Response({"login_url": login_url})
Ejemplo n.º 14
0
 def get(self, request):
     # next表示从哪个页面跳转过来,登录成功后就跳转那个页面
     next = request.GET.get('next')
     # 获取qq登录网址
     # 创建OAuthQQ类对象
     oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                     client_secret=settings.QQ_CLIENT_SECRET,
                     redirect_uri=settings.QQ_REDIRECT_URI,
                     state=next)
     # 调用对象的获取qq地址方法
     login_url = oauth.get_qq_url()
     # 返回登录地址
     return http.JsonResponse({'code': RETCODE.OK, 'login_url': login_url})
Ejemplo n.º 15
0
    def get(self, request):

        oauthqq = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                          client_secret=settings.QQ_CLIENT_SECRET,
                          redirect_uri=settings.QQ_REDIRECT_URI,
                          state="next")

        login_url = oauthqq.get_qq_url()

        return http.JsonResponse({
            'code': 1,
            "errmsg": "ok",
            "login_url": login_url
        })
Ejemplo n.º 16
0
 def get(self, request):
     # next表示从哪个页面进入到的登录页面,将来登录成功后,就自动回到那个页面
     next = request.GET.get('next')
     # 获取QQ登录页面网址
     oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                     client_secret=settings.QQ_CLIENT_SECRET,
                     redirect_uri=settings.QQ_REDIRECT_URI,
                     state=next)
     login_url = oauth.get_qq_url()
     return http.JsonResponse({
         'code': RETCODE.OK,
         'errmsg': 'OK',
         'login_url': login_url
     })
Ejemplo n.º 17
0
    def get(self, request):

        # 1.创建实例对象
        #client_id=None, client_secret=None, redirect_uri=None, state=None
        state = 'test'
        qqoauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                          client_secret=settings.QQ_CLIENT_SECRET,
                          redirect_uri=settings.QQ_REDIRECT_URI,
                          state=state)

        # 2.调用方法
        login_url = qqoauth.get_qq_url()

        return http.JsonResponse({'login_url': login_url})
Ejemplo n.º 18
0
 def get(self, request):
     # next表示从哪个页面进入登录页面
     next = request.GET.get('next')
     # 获取QQ授权登录页面地址
     oauth = OAuthQQ(client_id=settings.QQ_APP_ID,
                     client_secret=settings.QQ_APP_KEY,
                     redirect_uri=settings.QQ_REDIRECT_URI,
                     state=next)
     login_url = oauth.get_qq_url()
     return http.JsonResponse({
         'code': RETCODE.OK,
         'errmsg': 'OK',
         'login_url': login_url
     })
Ejemplo n.º 19
0
    def get(self, request):
        # 1.实例化对象--- 美多---认证---QQ
        oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                        client_secret=settings.QQ_CLIENT_SECRET,
                        redirect_uri=settings.QQ_REDIRECT_URI,
                        state=None)

        # 2.获取qq登录地址
        qq_login_url = oauth.get_qq_url()

        return http.JsonResponse({
            'code': 0,
            'errmsg': "获取qq登录地址",
            "login_url": qq_login_url
        })
Ejemplo n.º 20
0
    def get(self, request):

        # auth_url = 'http://www.meiduo.site:8080/oauth_callback.html'
        state = '/'
        # 1 创建oauth对象
        oauth = OAuthQQ(
            client_id=settings.QQ_CLIENT_ID,
            client_secret=settings.QQ_CLIENT_SECRET,
            redirect_uri=settings.QQ_REDIRECT_URI,
            state=state,
        )
        # 2 获取跳转的url
        auth_url = oauth.get_qq_url()

        return Response({"auth_url": auth_url})
Ejemplo n.º 21
0
 def get(self, request):
     # 1.获取查询参数
     next = request.GET.get('next')
     # 2.创建QQ登录工具对象
     qq_auth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                       client_secret=settings.QQ_CLIENT_SECRET,
                       redirect_uri=settings.QQ_REDIRECT_URI,
                       state=next)
     # QQ登录url
     qq_login_url = qq_auth.get_qq_url()
     return http.JsonResponse({
         'code': RETCODE.OK,
         'errmsg': 'OK',
         'login_url': qq_login_url
     })
Ejemplo n.º 22
0
    def get(self, request):
        # 生成授权地址
        next_url = request.GET.get('next')
        # 1.创建工具对象
        qq_tool = OAuthQQ(settings.QQ_CLIENT_ID, settings.QQ_CLIENT_SECRET,
                          settings.QQ_REDIRECT_URI, next_url)
        # 2.调用方法,生成url地址
        login_url = qq_tool.get_qq_url()

        # 响应
        return http.JsonResponse({
            'code': RETCODE.OK,
            'errmsg': 'ok',
            'login_url': login_url
        })
Ejemplo n.º 23
0
 def get(self, request):
     """提供QQ登录页面网址
         https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=xxx&redirect_uri=xxx&state=xxx
     """
     # 获取查询参数
     next = request.GET.get('next') or '/'
     # 创建oauth对象
     oauth_qq = OAuthQQ(client_id=QQ_CLIENT_ID, client_secret=QQ_CLIENT_SECRET, redirect_uri=QQ_REDIRECT_URI, state=next)
     login_url = oauth_qq.get_qq_url()
     data = {
         'code': RETCODE.OK,
         'errmsg': 'OK',
         'login_url': login_url
     }
     return http.JsonResponse(data)
Ejemplo n.º 24
0
    def get(self, request):
        # 获取前段state数据
        state = request.query_params.get('state', None)
        if state is None:
            state = '/'

        # 初始化生成qq对象
        oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                        client_secret=settings.QQ_CLIENT_SECRET,
                        redirect_uri=settings.QQ_REDIRECT_URI,
                        state=state)
        # 获取跳转连接
        qq_login_url = oauth.get_qq_url()
        # 返回跳转连接给前端
        return Response({'login_url': qq_login_url})
Ejemplo n.º 25
0
    def get(self, request):
        state = '/'

        # 1 创建 oauth对象
        #client_id=None, client_secret=None, redirect_uri=None, state=None
        oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                        client_secret=settings.QQ_CLIENT_SECRET,
                        redirect_uri=settings.QQ_REDIRECT_URI,
                        state=state)

        # 2 调用方法,获取url
        login_url = oauth.get_qq_url()
        # login_url="# login_url = 'https://graph.qq.com/oauth2.0/authorize?response_type=code&redirect_uri=http%3A%2F%2Fwww.meiduo.site%3A8080%2Foauth_callback.html&state=%2F&client_id=101474184'"

        return Response({"login_url": login_url})
Ejemplo n.º 26
0
 def get(self, request):
     # 1、获取前端  state
     state = request.query_params.get('next', None)
     # 2、前端没有传递state,需要手动指定
     if state is None:
         state = '/'
     # 3、初始化OAuthQQ对象
     qq = OAuthQQ(client_secret=settings.QQ_CLIENT_SECRET,
                  client_id=settings.QQ_CLIENT_ID,
                  redirect_uri=settings.QQ_REDIRECT_URI,
                  state=state)
     # 4、构建qq登录页面的跳转连接
     login_url = qq.get_qq_url()
     # 5、返回结果
     return Response({'login_url': login_url})
Ejemplo n.º 27
0
    def get(self, request):
        next_url = request.GET.get('next')

        # 创建授权对象
        oauthqq = OAuthQQ(settings.QQ_CLIENT_ID, settings.QQ_CLIENT_SECRET,
                          settings.QQ_REDIRECT_URI, next_url)
        # 生成授权地址
        login_url = oauthqq.get_qq_url()

        # 响应
        return http.JsonResponse({
            'code': RETCODE.OK,
            'errmsg': "OK",
            'login_url': login_url
        })
Ejemplo n.º 28
0
 def get(self, request):
     #1.创建实例
     next = request.GET.get('next')
     oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                     client_secret=settings.QQ_CLIENT_SECRET,
                     redirect_uri=settings.QQ_REDIRECT_URI,
                     state=next)
     #2.获取url
     login_url = oauth.get_qq_url()
     #3.返回相应
     return http.JsonResponse({
         'code': RETCODE.OK,
         'errmsg': 'ok',
         'login_url': login_url
     })
Ejemplo n.º 29
0
 def get(self, request):
     # 1.获取前端传递的state,key值为next
     state = request.query_params.get('next', None)
     # 2.判断state是否存在,没有则手动创建
     if not state:
         state = '/'
     # 3.初始化OAuthQQ对象
     qq = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                  client_secret=settings.QQ_CLIENT_SECRET,
                  redirect_uri=settings.QQ_REDIRECT_URI,
                  state=state)
     # 4.构造qq跳转链接
     login_url = qq.get_qq_url()
     # 5.返回结果
     return Response({'login_url': login_url})
Ejemplo n.º 30
0
 def get(self, request):
     # 1. 获取前端定义好的字符串数据
     state = request.query_params.get('next', None)
     # 2、判断前端是否传递字符串数据
     if not state:
         state = '/'
     # 3. 创建qq对象
     qq = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                  client_secret=settings.QQ_CLIENT_SECRET,
                  redirect_uri=settings.QQ_REDIRECT_URI,
                  state=state)
     # 4. 构建跳转链接
     login_url = qq.get_qq_url()
     # 5. 返回结果
     return Response({'login_url': login_url})
Ejemplo n.º 31
0
    def get(self,request):
    # next 表示从哪个页面进入到的登录页面,将来登录成功后,就自动回到那个页面
        next = request.GET.get('enxt')

        # 获取 QQ 登录页面网址
        # 创建 OAuthQQ 类的对象
        oauth = OAuthQQ(client_id=settings.QQ_CLIENT_ID,
                        client_secret=settings.QQ_CLIENT_SECRET,
                        redirect_uri=settings.QQ_REDIRECT_URI,
                        state=next)

        # 调用对象的获取 qq 地址方法
        login_url = oauth.get_qq_url()

        # 返回登陆地址
        return http.JsonResponse({'code': RETCODE.OK, 'errmsg': 'OK', 'login_url':login_url})