From 7561e1adbef02ab9389206245b77bb88a38e3c46 Mon Sep 17 00:00:00 2001 From: Aadesh-Baral Date: Sun, 6 Mar 2022 10:29:47 +0545 Subject: [PATCH] added function to generate authorization url --- flask_oauthlib/client.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/flask_oauthlib/client.py b/flask_oauthlib/client.py index b4497f46..5711433f 100644 --- a/flask_oauthlib/client.py +++ b/flask_oauthlib/client.py @@ -506,15 +506,15 @@ def request(self, url, data=None, headers=None, format='urlencoded', ) return OAuthResponse(resp, content, self.content_type) - def authorize(self, callback=None, state=None, **kwargs): + + def generate_authorize_url(self, callback=None, state=None, **kwargs): """ - Returns a redirect response to the remote authorization URL with - the signed callback given. + Returns remote authorization URL. :param callback: a redirect url for the callback :param state: an optional value to embed in the OAuth request. - Use this if you want to pass around application - state (e.g. CSRF tokens). + Use this if you want to pass around application + state (e.g. CSRF tokens). :param kwargs: add optional key/value pairs to the query string """ params = dict(self.request_token_params) or {} @@ -560,6 +560,25 @@ def authorize(self, callback=None, state=None, **kwargs): state=state, **params ) + return url + + + def authorize(self, callback=None, state=None, **kwargs): + """ + Returns a redirect response to the remote authorization URL with + the signed callback given. + + :param callback: a redirect url for the callback + :param state: an optional value to embed in the OAuth request. + Use this if you want to pass around application + state (e.g. CSRF tokens). + :param kwargs: add optional key/value pairs to the query string + """ + url = self.generate_authorize_url( + callback=callback, + state=state, + **kwargs + ) return redirect(url) def tokengetter(self, f):