MCPcopy Create free account
hub / github.com/dwavesystems/dwave-cloud-client / AuthFlow

Class AuthFlow

dwave/cloud/auth/flows.py:47–289  ·  view source on GitHub ↗

`OAuth 2.0 Authorization Code`_ exchange flow with `PKCE`_ extension for public (secretless) clients. Args: client_id: OAuth 2.0 Client ID. scopes: List of requested scopes. redirect_uri: Redirect URI that was registered as callbac

Source from the content-addressed store, hash-verified

45
46
47class AuthFlow:
48 """`OAuth 2.0 Authorization Code`_ exchange flow with `PKCE`_ extension
49 for public (secretless) clients.
50
51 Args:
52 client_id:
53 OAuth 2.0 Client ID.
54 scopes:
55 List of requested scopes.
56 redirect_uri:
57 Redirect URI that was registered as callback for client identified
58 with ``client_id``.
59 authorization_endpoint:
60 URL of the authorization server's authorization endpoint.
61 token_endpoint:
62 URL of the authorization server's token endpoint.
63 revocation_endpoint:
64 URL of the authorization server's OAuth 2.0 revocation endpoint.
65 session_config:
66 Configuration options for the low-level ``requests.Session`` used
67 for all OAuth 2 requests. Supported options are: ``cert``,
68 ``cookies``, ``headers``, ``proxies``, ``timeout``, ``verify``.
69 leap_api_endpoint:
70 Leap API endpoint, optional. Used to scope the token in credentials
71 store.
72 creds:
73 :class:`~dwave.cloud.auth.creds.Credentials` store used to persist
74 the token fetched.
75
76 .. _OAuth 2.0 Authorization Code:
77 https://datatracker.ietf.org/doc/html/rfc6749#section-4.1
78 .. _PKCE:
79 https://datatracker.ietf.org/doc/html/rfc7636
80 """
81
82 def __init__(self, *,
83 client_id: str,
84 scopes: abc.Sequence[str],
85 redirect_uri: str,
86 authorization_endpoint: str,
87 token_endpoint: str,
88 revocation_endpoint: Optional[str] = None,
89 session_config: Optional[abc.Mapping[str, Any]] = None,
90 leap_api_endpoint: Optional[str] = None,
91 creds: Optional[Credentials] = None
92 ):
93 self.client_id = client_id
94 self.scopes = ' '.join(scopes)
95 self.authorization_endpoint = authorization_endpoint
96 self.token_endpoint = token_endpoint
97 self.revocation_endpoint = revocation_endpoint
98 self.leap_api_endpoint = leap_api_endpoint
99 self.creds = creds
100
101 # TODO: verify authorization/token/revocation endpoints are https
102
103 self.session = OAuth2Session(
104 client_id=client_id, scope=scopes, redirect_uri=redirect_uri,

Calls

no outgoing calls