Beispiel #1
0
 def _oauth_request_token_url(self, redirect_uri= None, client_id = None,
                              client_secret=None, code=None,
                              extra_params=None):
     url = self._OAUTH_ACCESS_TOKEN_URL
     args = dict(
         redirect_uri=redirect_uri,
         code=code,
         client_id=client_id,
         client_secret=client_secret,
         )
     if extra_params: args.update(extra_params)
     return url_concat(url, args)
Beispiel #2
0
    def authorize_redirect(self, redirect_uri=None, client_id=None,
                           client_secret=None, extra_params=None ):
        """Redirects the user to obtain OAuth authorization for this service.

        Some providers require that you register a Callback
        URL with your application. You should call this method to log the
        user in, and then call get_authenticated_user() in the handler
        you registered as your Callback URL to complete the authorization
        process.
        """
        args = {
          "redirect_uri": redirect_uri,
          "client_id": client_id
        }
        if extra_params: args.update(extra_params)
        self.redirect(
                url_concat(self._OAUTH_AUTHORIZE_URL, args))
Beispiel #3
0
 def test_url_concat_no_query_params(self):
     url = url_concat(
             "https://localhost/path",
             {'y':'y', 'z':'z'},
             )
     self.assertEqual(url, "https://localhost/path?y=y&z=z")
Beispiel #4
0
 def test_url_concat_mult_params(self):
     url = url_concat(
             "https://localhost/path?a=1&b=2",
             {'y':'y', 'z':'z'},
             )
     self.assertEqual(url, "https://localhost/path?a=1&b=2&y=y&z=z")
Beispiel #5
0
 def test_url_concat_trailing_amp(self):
     url = url_concat(
             "https://localhost/path?x&",
             {'y':'y', 'z':'z'},
             )
     self.assertEqual(url, "https://localhost/path?x&y=y&z=z")
Beispiel #6
0
 def test_url_concat_encode_args(self):
     url = url_concat(
             "https://localhost/path",
             {'y':'/y', 'z':'z'},
             )
     self.assertEqual(url, "https://localhost/path?y=%2Fy&z=z")