Auth(reddit: praw.Reddit, _data: Optional[Dict[str, Any]])¶
Auth provides an interface to Reddit’s authorization.
__init__(reddit: praw.Reddit, _data: Optional[Dict[str, Any]])¶
Initialize a PRAWModel instance.
reddit – An instance of
Complete the web authorization flow and return the refresh token.
code – The code obtained through the request to the redirect uri.
The obtained refresh token, if available, otherwise
The session’s active authorization will be updated upon success.
implicit(access_token: str, expires_in: int, scope: str) → None¶
Set the active authorization to be an implicit authorization.
access_token – The access_token obtained from Reddit’s callback.
expires_in – The number of seconds the
access_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 – A space-delimited string of Reddit OAuth2 scope names as returned from Reddit’s callback.
Return a dictionary containing the rate limit info.
The keys are:
The number of requests remaining to be made in the current rate limit window.
A unix timestamp providing an upper bound on when the rate limit counters will reset.
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.
reset_timestampvalue is an upper bound as the real timestamp is computed on Reddit’s end in preparation for sending the response. This value may change slightly within a given window due to slight changes in response times and rounding.
parse(data: Dict[str, Any], reddit: praw.Reddit) → Any¶
Return an instance of
data – The structured data.
reddit – An instance of
scopes() → Set[str]¶
Return a set of scopes included in the current authorization.
For read-only authorizations this should return
url(scopes: List[str], state: str, duration: str = 'permanent', implicit: bool = False) → str¶
Return the URL used out-of-band to grant access to your application.
scopes – A list of OAuth scopes to request authorization for.
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.
duration – Either
temporaryauthorizations generate access tokens that last only 1 hour.
permanentauthorizations additionally generate a single-use refresh token with a significantly longer expiration (~1 year) that is to be used to fetch a new set of tokens. This value is ignored when
implicit – For installed applications, this value can be set to use the implicit, rather than the code flow. When True, the
durationargument has no effect as only temporary tokens can be retrieved.
refresh_tokenscurrently are reusable, and do not expire. However, that behavior is likely to change in the near future so it’s best to no longer rely upon it: https://old.reddit.com/r/redditdev/comments/kvzaot/oauth2_api_changes_upcoming/