Exemplo n.º 1
0
    def setUp(self):

        self.client = Client(client_id='some.client',
                             client_secret='ASDFGHJKL',
                             redirect_uri='https://example.com/oauth2redirect',
                             authorization_uri='https://myapp.com/oauth2/auth',
                             token_uri='https://myapp.com/oauth2/token')
Exemplo n.º 2
0
    def setUp(self):

        self.client = Client(client_id='some.client',
                             client_secret='ASDFGHJKL',
                             redirect_uri='https://example.com/oauth2redirect',
                             authorization_uri='https://myapp.com/oauth2/auth',
                             token_uri='https://myapp.com/oauth2/token')
Exemplo n.º 3
0
class ClientTest(unittest.TestCase):
    def setUp(self):

        self.client = Client(client_id='some.client',
                             client_secret='ASDFGHJKL',
                             redirect_uri='https://example.com/oauth2redirect',
                             authorization_uri='https://myapp.com/oauth2/auth',
                             token_uri='https://myapp.com/oauth2/token')

    def test_get_authorization_code_uri(self):
        """Test client generation of authorization code uri."""
        uri = self.client.get_authorization_code_uri(state="app.state")

        # Check URI
        self.assertTrue(uri.startswith('https://myapp.com/oauth2/auth?'))

        # Check params
        params = utils.url_query_params(uri)
        self.assertEquals('code', params['response_type'])
        self.assertEquals('some.client', params['client_id'])
        self.assertEquals('https://example.com/oauth2redirect',
                          params['redirect_uri'])
        self.assertEquals('app.state', params['state'])
Exemplo n.º 4
0
class ClientTest(unittest.TestCase):

    def setUp(self):

        self.client = Client(client_id='some.client',
                             client_secret='ASDFGHJKL',
                             redirect_uri='https://example.com/oauth2redirect',
                             authorization_uri='https://myapp.com/oauth2/auth',
                             token_uri='https://myapp.com/oauth2/token')

    def test_get_authorization_code_uri(self):
        """Test client generation of authorization code uri."""
        uri = self.client.get_authorization_code_uri(state="app.state")

        # Check URI
        self.assertTrue(uri.startswith('https://myapp.com/oauth2/auth?'))

        # Check params
        params = utils.url_query_params(uri)
        self.assertEquals('code', params['response_type'])
        self.assertEquals('some.client', params['client_id'])
        self.assertEquals('https://example.com/oauth2redirect', params['redirect_uri'])
        self.assertEquals('app.state', params['state'])
Exemplo n.º 5
0
class MainHandler(tornado.web.RequestHandler):
    client = Client(client_id=CLIENT_ID,
                    client_secret=CLIENT_SECRET,
                    authorization_uri=SERVER_URI + '/authorize',
                    token_uri=SERVER_URI + '/token',
                    redirect_uri=REDIRECT_URI + '?param=123')
    provider = MockAuthorizationProvider()
    uri = client.get_authorization_code_uri()
    data = provider.get_authorization_code_from_uri(uri)
    logger = logging.getLogger(data)

    print(data.headers)

    def get(self):
        self.write("""<html>
    <body>
        <p>
            <a href="https://localhost:8888/callback?confirm=1">confirm</a>
        </p>
        <p>
            <a href="https://localhost:8888/callback?confirm=0">deny</a>
        </p>
    </body>
</html>""")