def test_build_url(self): """Test that build_url properly adds query parameters.""" result = utils.build_url(self.base_url, {'b': 20}) # Note param ordering and correct new value for b self.assertEquals( result, 'https://www.myapp.com/some/path;hello?a=10&c=30&b=20')
def get_token_response(self, response_type, client_id, redirect_uri, **params): # Ensure proper response_type if response_type != "token": err = "unsupported_response_type" return self._make_redirect_error_response(redirect_uri, err) # Check for a valid client ID. is_valid_client_id = self.validate_client_id(client_id) if not is_valid_client_id: err = "unauthorized_client" return self._make_redirect_error_response(redirect_uri, err) # Check for a valid redirect URI. is_valid_redirect_uri = self.validate_redirect_uri( client_id, redirect_uri) if not is_valid_redirect_uri: return self._invalid_redirect_uri_response() # Check conditions is_valid_access = self.validate_access() scope = params.get("scope", "") are_valid_scopes = self.validate_scope(client_id, scope) # Return proper error responses on invalid conditions if not is_valid_access: err = "access_denied" return self._make_redirect_error_response(redirect_uri, err) if not are_valid_scopes: err = "invalid_scope" return self._make_redirect_error_response(redirect_uri, err) # Make sure we have enough random data in the token to have a public # prefix and a private encrypted suffix. access_token = str(self.generate_access_token()) assert len(access_token) - ACCESS_TOKEN_PREFIX_LENGTH >= 20 token_type = self.token_type expires_in = self.token_expires_in data = self._generate_data_string() self.persist_token_information( client_id=client_id, scope=scope, access_token=access_token, token_type=token_type, expires_in=expires_in, refresh_token=None, data=data, ) url = utils.build_url(redirect_uri, params) url += "#access_token=%s&token_type=%s&expires_in=%s" % ( access_token, token_type, expires_in, ) return self._make_response(headers={"Location": url}, status_code=302)
def test_build_url(self): """Test that build_url properly adds query parameters.""" result = utils.build_url(self.base_url, {'b': 20}) # Note param ordering and correct new value for b self.assertEquals( result, 'https://www.myapp.com/some/path;hello?a=10&c=30&b=20' )