def _generate_location(self, code): query = "code=" + code if self.state is not None: query += "&state=" + quote(self.state) return "%s?%s" % (self.client.redirect_uri, query)
def _generate_location(self, code): query = "code=" + code if self.state is not None: query += "&state=" + self.state if self.scope_handler.send_back is True: query += "&scope=" + quote(" ".join(self.scope_handler.scopes)) return "%s?%s" % (self.redirect_uri, query)
def encode_scopes(scopes, use_quote=False): """ Creates a string out of a list of scopes. :param scopes: A list of scopes :param use_quote: Boolean flag indicating whether the string should be quoted :return: Scopes as a string """ scopes_as_string = Scope.separator.join(scopes) if use_quote: return quote(scopes_as_string) return scopes_as_string
def _redirect_access_token(self, response, token): uri_with_fragment = "{0}#access_token={1}&token_type=bearer". \ format(self.client.redirect_uri, token) if self.state is not None: uri_with_fragment += "&state=" + quote(self.state) if self.scope_handler.send_back is True: scopes_as_string = encode_scopes(self.scope_handler.scopes, use_quote=True) uri_with_fragment += "&scope=" + scopes_as_string response.status_code = 302 response.add_header("Location", uri_with_fragment) response.content = "" return response