예제 #1
0
 def test_callback_status_code_error(self):
     mocker = OauthTokenMocker()
     mocker.expect_token_request(status_code=400)
     with mocker:
         with assert_raises(google.OAuthError):
             google.handle_callback(self.make_mock_callback_request(),
                                    mocker.redirect_uri)
예제 #2
0
 def test_callback_error(self):
     mocker = OauthTokenMocker()
     mocker.expect_token_request(response_data={'error': 'test-error'})
     with mocker:
         with assert_raises(google.OAuthError):
             google.handle_callback(self.make_mock_callback_request(),
                                    mocker.redirect_uri)
예제 #3
0
 def test_callback_for_offline_access(self):
     mocker = OauthTokenMocker()
     mocker.expect_token_request(refresh_token='test-refresh-token')
     with mocker:
         auth_info = google.handle_callback(
             self.make_mock_callback_request(), mocker.redirect_uri)
     self.assertEqual(auth_info.refresh_token, 'test-refresh-token')
예제 #4
0
파일: views.py 프로젝트: oaleeapp/EguoWorld
def google_callback(request):
    try:
        auth_info = google.handle_callback(request, google_callback_url())
    except google.APIError, e:
        logging.error("google_callback: %s" % e)
        messages.error(request, e.message)
        # there's no good place to redirect the user to since we don't know
        # what team/user they were trying to add the account for.  I guess the
        # homepage is as good as any.
        return redirect('videos.views.index')
예제 #5
0
 def test_callback(self):
     mocker = OauthTokenMocker()
     mocker.expect_token_request()
     with mocker:
         auth_info = google.handle_callback(
             self.make_mock_callback_request(), mocker.redirect_uri)
     self.assertEqual(auth_info.access_token, mocker.access_token)
     self.assertEqual(auth_info.refresh_token, None)
     self.assertEqual(auth_info.openid_id, '')
     self.assertEqual(auth_info.sub, mocker.sub)
     self.assertEqual(auth_info.state, self.test_state)