當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。