Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add function to generate authorization url #402

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions flask_oauthlib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down Expand Up @@ -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):
Expand Down