Auth¶
- class praw.models.Auth(reddit, _data)¶
Auth provides an interface to Reddit’s authorization.
- Parameters:
reddit (praw.Reddit)
- authorize(code)¶
Complete the web authorization flow and return the refresh token.
- Parameters:
code (
str) – The code obtained through the request to the redirect uri.- Return type:
- Returns:
The obtained refresh token, if available, otherwise
None.
The session’s active authorization will be updated upon success.
- implicit(*, access_token, expires_in, scope)¶
Set the active authorization to be an implicit authorization.
- Parameters:
access_token (
str) – The access_token obtained from Reddit’s callback.expires_in (
int) – The number of seconds theaccess_tokenis valid for. The origin of this value was returned from Reddit’s callback. You may need to subtract an offset before passing in this number to account for a delay between when Reddit prepared the response, and when you make this function call.scope (
str) – A space-delimited string of Reddit OAuth2 scope names as returned from Reddit’s callback.
- Raises:
InvalidImplicitAuthifRedditwas initialized for a non-installed application type.- Return type:
- property limits: dict[str, str | int | None]¶
Return a dictionary containing the rate limit info.
The keys are:
- Remaining:
The number of requests remaining to be made in the current rate limit window.
- Used:
The number of requests made in the current rate limit window.
All values are initially
Noneas these values are set in response to issued requests.
- classmethod parse(data, reddit)¶
Return an instance of
clsfromdata.
- scopes()¶
Return a set of scopes included in the current authorization.
For read-only authorizations this should return
{"*"}.
- url(*, duration='permanent', implicit=False, scopes, state)¶
Return the URL used out-of-band to grant access to your application.
- Parameters:
duration (
str) – Either"permanent"or"temporary"(default:"permanent")."temporary"authorizations generate access tokens that last only 1 hour."permanent"authorizations additionally generate a refresh token that expires 1 year after the last use and can be used indefinitely to generate new hour-long access tokens. This value is ignored whenimplicit=True.implicit (
bool) – For installed applications, this value can be set to use the implicit, rather than the code flow. WhenTrue, thedurationargument has no effect as only temporary tokens can be retrieved.scopes (
list[str]) – A list of OAuth scopes to request authorization for.state (
str) – A string that will be reflected in the callback toredirect_uri. This value should be temporarily unique to the client for whom the URL was generated for.
- Return type: