本文整理匯總了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')
示例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)
示例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)
示例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)
示例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)
示例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)