def test_oauth2_fetch_access_token(self):
     url = 'https://example.com/token'
     token = get_bearer_token()
     client = OAuthClient(client_id='foo', access_token_url=url)
     client.session.send = mock_json_response(token)
     self.assertEqual(client.fetch_access_token(), token)
     self.assertEqual(client.fetch_access_token(url), token)
示例#2
0
 def test_oauth2_fetch_access_token(self):
     url = 'https://example.com/token'
     token = get_bearer_token()
     with mock.patch('requests.sessions.Session.send') as send:
         send.return_value = mock_send_value(token)
         client = OAuthClient(client_id='foo', access_token_url=url)
         self.assertEqual(client.fetch_access_token(), token)
         self.assertEqual(client.fetch_access_token(url), token)
示例#3
0
    def test_oauth1_fetch_access_token(self):
        with mock.patch('requests.sessions.Session.send') as send:
            send.return_value = mock_send_value('oauth_token=foo')
            client = OAuthClient('foo',
                                 request_token_url='https://a.com/req',
                                 access_token_url='https://example.com/token')

            request_token = {'oauth_token': 'req'}
            resp = client.fetch_access_token(request_token=request_token,
                                             oauth_verifier='bar')
            self.assertEqual(resp['oauth_token'], 'foo')
    def test_oauth1_fetch_access_token(self):
        client = OAuthClient('foo',
                             request_token_url='https://a.com/req',
                             access_token_url='https://example.com/token')

        request_token = {'oauth_token': 'req'}

        client.session.send = mock_text_response('oauth_token=foo')
        resp = client.fetch_access_token(request_token=request_token,
                                         oauth_verifier='bar')
        self.assertEqual(resp['oauth_token'], 'foo')