Skip to content

Commit

Permalink
Add Reddit.auth.url.
Browse files Browse the repository at this point in the history
  • Loading branch information
bboe committed Aug 8, 2016
1 parent f3706fd commit 1761f5a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions praw/models/auth.py
Expand Up @@ -31,3 +31,24 @@ def implicit(self, access_token, expires_in, scope):
implicit_session = session(ImplicitAuthorizer(
authenticator, access_token, expires_in, scope))
self._reddit._core = self._reddit._authorized_core = implicit_session

def url(self, scopes, state, duration=None):
"""Return the URL used out-of-band to grant access to your application.
:param scopes: A list of OAuth scopes to request authorization for.
:param state: A string that will be reflected in the callback to
``redirect_uri``. This value should be temporarily unique to the
client for whom the URL was generated for.
:param duration: (web app only) Either ``permanent`` or
``temporary``. ``temporary`` authorizations generate access tokens
that last only 1 hour. ``permanent`` authorizations additionally
generate a refresh token that can be indefinitely used to generate
new hour-long access tokens.
"""
authenticator = self._reddit._read_only_core._authorizer._authenticator
if isinstance(authenticator, UntrustedAuthenticator):
if duration is not None:
raise ClientException('installed apps cannot specify duration')
return authenticator.authorize_url(scopes, state)
return authenticator.authorize_url(duration, scopes, state)

0 comments on commit 1761f5a

Please sign in to comment.