Construct a new OAuth 2 client requests session. :param client_id: Client ID, which you get from client registration. :param client_secret: Client Secret, which you get from registration. :param authorization_endpoint: URL of the authorization server's authorization endpoint.
| 44 | |
| 45 | |
| 46 | class OAuth2Session(OAuth2Client, Session): |
| 47 | """Construct a new OAuth 2 client requests session. |
| 48 | |
| 49 | :param client_id: Client ID, which you get from client registration. |
| 50 | :param client_secret: Client Secret, which you get from registration. |
| 51 | :param authorization_endpoint: URL of the authorization server's |
| 52 | authorization endpoint. |
| 53 | :param token_endpoint: URL of the authorization server's token endpoint. |
| 54 | :param token_endpoint_auth_method: client authentication method for |
| 55 | token endpoint. |
| 56 | :param revocation_endpoint: URL of the authorization server's OAuth 2.0 |
| 57 | revocation endpoint. |
| 58 | :param revocation_endpoint_auth_method: client authentication method for |
| 59 | revocation endpoint. |
| 60 | :param scope: Scope that you needed to access user resources. |
| 61 | :param state: Shared secret to prevent CSRF attack. |
| 62 | :param redirect_uri: Redirect URI you registered as callback. |
| 63 | :param token: A dict of token attributes such as ``access_token``, |
| 64 | ``token_type`` and ``expires_at``. |
| 65 | :param token_placement: The place to put token in HTTP request. Available |
| 66 | values: "header", "body", "uri". |
| 67 | :param update_token: A function for you to update token. It accept a |
| 68 | :class:`OAuth2Token` as parameter. |
| 69 | :param leeway: Time window in seconds before the actual expiration of the |
| 70 | authentication token, that the token is considered expired and will |
| 71 | be refreshed. |
| 72 | :param default_timeout: If settled, every requests will have a default timeout. |
| 73 | """ |
| 74 | |
| 75 | client_auth_class = OAuth2ClientAuth |
| 76 | token_auth_class = OAuth2Auth |
| 77 | oauth_error_class = OAuthError |
| 78 | SESSION_REQUEST_PARAMS = ( |
| 79 | "allow_redirects", |
| 80 | "timeout", |
| 81 | "cookies", |
| 82 | "files", |
| 83 | "proxies", |
| 84 | "hooks", |
| 85 | "stream", |
| 86 | "verify", |
| 87 | "cert", |
| 88 | "json", |
| 89 | ) |
| 90 | |
| 91 | def __init__( |
| 92 | self, |
| 93 | client_id=None, |
| 94 | client_secret=None, |
| 95 | token_endpoint_auth_method=None, |
| 96 | revocation_endpoint_auth_method=None, |
| 97 | scope=None, |
| 98 | state=None, |
| 99 | redirect_uri=None, |
| 100 | token=None, |
| 101 | token_placement="header", |
| 102 | update_token=None, |
| 103 | leeway=60, |
no outgoing calls
searching dependent graphs…