MCPcopy Create free account
hub / github.com/authlib/authlib / parse_authorization_code_response

Function parse_authorization_code_response

authlib/oauth2/rfc6749/parameters.py:103–151  ·  view source on GitHub ↗

Parse authorization grant response URI into a dict. If the resource owner grants the access request, the authorization server issues an authorization code and delivers it to the client by adding the following parameters to the query component of the redirection URI using the ``appli

(uri, state=None)

Source from the content-addressed store, hash-verified

101
102
103def parse_authorization_code_response(uri, state=None):
104 """Parse authorization grant response URI into a dict.
105
106 If the resource owner grants the access request, the authorization
107 server issues an authorization code and delivers it to the client by
108 adding the following parameters to the query component of the
109 redirection URI using the ``application/x-www-form-urlencoded`` format:
110
111 **code**
112 REQUIRED. The authorization code generated by the
113 authorization server. The authorization code MUST expire
114 shortly after it is issued to mitigate the risk of leaks. A
115 maximum authorization code lifetime of 10 minutes is
116 RECOMMENDED. The client MUST NOT use the authorization code
117 more than once. If an authorization code is used more than
118 once, the authorization server MUST deny the request and SHOULD
119 revoke (when possible) all tokens previously issued based on
120 that authorization code. The authorization code is bound to
121 the client identifier and redirection URI.
122
123 **state**
124 REQUIRED if the "state" parameter was present in the client
125 authorization request. The exact value received from the
126 client.
127
128 :param uri: The full redirect URL back to the client.
129 :param state: The state parameter from the authorization request.
130
131 For example, the authorization server redirects the user-agent by
132 sending the following HTTP response:
133
134 .. code-block:: http
135
136 HTTP/1.1 302 Found
137 Location: https://client.example.com/cb?code=SplxlOBeZQQYbYS6WxSbIA
138 &state=xyz
139
140 """
141 query = urlparse.urlparse(uri).query
142 params = dict(urlparse.parse_qsl(query))
143
144 if "code" not in params:
145 raise MissingCodeException()
146
147 params_state = params.get("state")
148 if state and params_state != state:
149 raise MismatchingStateException()
150
151 return params
152
153
154def parse_implicit_response(uri, state=None):

Callers 1

fetch_tokenMethod · 0.85

Calls 3

getMethod · 0.45

Tested by

no test coverage detected