Exemplo n.º 1
0
    def step1_get_authorize_url(self, redirect_uri=None):
        """Returns a URI to redirect to the provider.

        Args:
          redirect_uri: string, Either the string 'urn:ietf:wg:oauth:2.0:oob' for
            a non-web-based application, or a URI that handles the callback from
            the authorization server. This parameter is deprecated, please move to
            passing the redirect_uri in via the constructor.

        Returns:
          A URI as a string to redirect the user to begin the authorization flow.
        """
        if redirect_uri is not None:
            logger.warning(('The redirect_uri parameter for'
                            'OAuth2WebServerFlow.step1_get_authorize_url is deprecated. Please'
                            'move to passing the redirect_uri in via the constructor.'))
            self.redirect_uri = redirect_uri

        if self.redirect_uri is None:
            raise ValueError('The value of redirect_uri must not be None.')

        query_params = {
            'client_id': self.client_id,
            'redirect_uri': self.redirect_uri,
            'scope': self.scope,
        }
        query_params.update(self.params)
        return _update_query_params(self.auth_uri, query_params)
Exemplo n.º 2
0
    def step1_get_authorize_url(self, redirect_uri=None):
        """Returns a URI to redirect to the provider.

        Args:
          redirect_uri: string, Either the string 'urn:ietf:wg:oauth:2.0:oob' for
            a non-web-based application, or a URI that handles the callback from
            the authorization server. This parameter is deprecated, please move to
            passing the redirect_uri in via the constructor.

        Returns:
          A URI as a string to redirect the user to begin the authorization flow.
        """
        if redirect_uri is not None:
            logger.warning((
                'The redirect_uri parameter for'
                'OAuth2WebServerFlow.step1_get_authorize_url is deprecated. Please'
                'move to passing the redirect_uri in via the constructor.'))
            self.redirect_uri = redirect_uri

        if self.redirect_uri is None:
            raise ValueError('The value of redirect_uri must not be None.')

        query_params = {
            'client_id': self.client_id,
            'redirect_uri': self.redirect_uri,
            'scope': self.scope,
        }
        query_params.update(self.params)
        return _update_query_params(self.auth_uri, query_params)
Exemplo n.º 3
0
 def test_update_query_params_existing_params(self):
     uri = 'http://www.google.com?x=y'
     updated = _update_query_params(uri, {'a': 'b', 'c': 'd&'})
     hardcoded_update = uri + '&a=b&c=d%26'
     assertUrisEqual(self, updated, hardcoded_update)
Exemplo n.º 4
0
 def test_update_query_params_no_params(self):
     uri = 'http://www.google.com'
     updated = _update_query_params(uri, {'a': 'b'})
     self.assertEqual(updated, uri + '?a=b')
 def test_update_query_params_existing_params(self):
   uri = 'http://www.google.com?x=y'
   updated = _update_query_params(uri, {'a': 'b', 'c': 'd&'})
   hardcoded_update = uri + '&a=b&c=d%26'
   assertUrisEqual(self, updated, hardcoded_update)
 def test_update_query_params_no_params(self):
   uri = 'http://www.google.com'
   updated = _update_query_params(uri, {'a': 'b'})
   self.assertEqual(updated, uri + '?a=b')
 def test_update_query_params_existing_params(self):
     uri = "http://www.google.com?x=y"
     updated = _update_query_params(uri, {"a": "b", "c": "d&"})
     hardcoded_update = uri + "&a=b&c=d%26"
     assertUrisEqual(self, updated, hardcoded_update)
 def test_update_query_params_no_params(self):
     uri = "http://www.google.com"
     updated = _update_query_params(uri, {"a": "b"})
     self.assertEqual(updated, uri + "?a=b")