当前位置: 首页>>代码示例>>Python>>正文


Python views.oauth2_authorize方法代码示例

本文整理汇总了Python中oauth2client.contrib.django_util.views.oauth2_authorize方法的典型用法代码示例。如果您正苦于以下问题:Python views.oauth2_authorize方法的具体用法?Python views.oauth2_authorize怎么用?Python views.oauth2_authorize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oauth2client.contrib.django_util.views的用法示例。


在下文中一共展示了views.oauth2_authorize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_already_authorized

# 需要导入模块: from oauth2client.contrib.django_util import views [as 别名]
# 或者: from oauth2client.contrib.django_util.views import oauth2_authorize [as 别名]
def test_already_authorized(self):
        request = self.factory.get('oauth2/oauth2authorize',
                                   data={'return_url': '/return_endpoint'})
        request.session = self.session

        authorized_user = django_models.User.objects.create_user(
            username='bill2', email='[email protected]', password='hunter2')

        credentials = _Credentials()
        tests_models.CredentialsModel.objects.create(
            user_id=authorized_user,
            credentials=credentials)

        request.user = authorized_user
        response = views.oauth2_authorize(request)
        self.assertIsInstance(response, http.HttpResponseRedirect)
        self.assertEqual(response.url, '/return_endpoint') 
开发者ID:openstack,项目名称:deb-python-oauth2client,代码行数:19,代码来源:test_views.py

示例2: test_authorize_works

# 需要导入模块: from oauth2client.contrib.django_util import views [as 别名]
# 或者: from oauth2client.contrib.django_util.views import oauth2_authorize [as 别名]
def test_authorize_works(self):
        request = self.factory.get('oauth2/oauth2authorize')
        request.session = self.session
        request.user = self.user
        response = views.oauth2_authorize(request)
        self.assertIsInstance(response, http.HttpResponseRedirect) 
开发者ID:openstack,项目名称:deb-python-oauth2client,代码行数:8,代码来源:test_views.py

示例3: test_authorize_anonymous_user

# 需要导入模块: from oauth2client.contrib.django_util import views [as 别名]
# 或者: from oauth2client.contrib.django_util.views import oauth2_authorize [as 别名]
def test_authorize_anonymous_user(self):
        request = self.factory.get('oauth2/oauth2authorize')
        request.session = self.session
        request.user = django_models.AnonymousUser()
        response = views.oauth2_authorize(request)
        self.assertIsInstance(response, http.HttpResponseRedirect) 
开发者ID:openstack,项目名称:deb-python-oauth2client,代码行数:8,代码来源:test_views.py

示例4: test_authorize_works_explicit_return_url

# 需要导入模块: from oauth2client.contrib.django_util import views [as 别名]
# 或者: from oauth2client.contrib.django_util.views import oauth2_authorize [as 别名]
def test_authorize_works_explicit_return_url(self):
        request = self.factory.get('oauth2/oauth2authorize',
                                   data={'return_url': '/return_endpoint'})
        request.session = self.session
        request.user = self.user
        response = views.oauth2_authorize(request)
        self.assertIsInstance(response, http.HttpResponseRedirect) 
开发者ID:openstack,项目名称:deb-python-oauth2client,代码行数:9,代码来源:test_views.py

示例5: test_authorize_anonymous_user_redirects_login

# 需要导入模块: from oauth2client.contrib.django_util import views [as 别名]
# 或者: from oauth2client.contrib.django_util.views import oauth2_authorize [as 别名]
def test_authorize_anonymous_user_redirects_login(self):
        request = self.factory.get('oauth2/oauth2authorize')
        request.session = self.session
        request.user = django_models.AnonymousUser()
        response = views.oauth2_authorize(request)
        self.assertIsInstance(response, http.HttpResponseRedirect)
        # redirects to Django login
        self.assertIn(django.conf.settings.LOGIN_URL, response.url) 
开发者ID:openstack,项目名称:deb-python-oauth2client,代码行数:10,代码来源:test_views.py

示例6: test_authorized_user_no_credentials_redirects

# 需要导入模块: from oauth2client.contrib.django_util import views [as 别名]
# 或者: from oauth2client.contrib.django_util.views import oauth2_authorize [as 别名]
def test_authorized_user_no_credentials_redirects(self):
        request = self.factory.get('oauth2/oauth2authorize',
                                   data={'return_url': '/return_endpoint'})
        request.session = self.session

        authorized_user = django_models.User.objects.create_user(
            username='bill2', email='[email protected]', password='hunter2')

        tests_models.CredentialsModel.objects.create(
            user_id=authorized_user,
            credentials=None)

        request.user = authorized_user
        response = views.oauth2_authorize(request)
        self.assertIsInstance(response, http.HttpResponseRedirect) 
开发者ID:openstack,项目名称:deb-python-oauth2client,代码行数:17,代码来源:test_views.py


注:本文中的oauth2client.contrib.django_util.views.oauth2_authorize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。