MCPcopy
hub / github.com/authlib/authlib / parse_implicit_response

Function parse_implicit_response

authlib/oauth2/rfc6749/parameters.py:161–214  ·  view source on GitHub ↗

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

(uri, state=None)

Source from the content-addressed store, hash-verified

159
160
161def parse_implicit_response(uri, state=None):
162 """Parse the implicit token response URI into a dict.
163
164 If the resource owner grants the access request, the authorization
165 server issues an access token and delivers it to the client by adding
166 the following parameters to the fragment component of the redirection
167 URI using the ``application/x-www-form-urlencoded`` format:
168
169 **access_token**
170 REQUIRED. The access token issued by the authorization server.
171
172 **token_type**
173 REQUIRED. The type of the token issued as described in
174 Section 7.1. Value is case insensitive.
175
176 **expires_in**
177 RECOMMENDED. The lifetime in seconds of the access token. For
178 example, the value "3600" denotes that the access token will
179 expire in one hour from the time the response was generated.
180 If omitted, the authorization server SHOULD provide the
181 expiration time via other means or document the default value.
182
183 **scope**
184 OPTIONAL, if identical to the scope requested by the client,
185 otherwise REQUIRED. The scope of the access token as described
186 by Section 3.3.
187
188 **state**
189 REQUIRED if the "state" parameter was present in the client
190 authorization request. The exact value received from the
191 client.
192
193 Similar to the authorization code response, but with a full token provided
194 in the URL fragment:
195
196 .. code-block:: http
197
198 HTTP/1.1 302 Found
199 Location: http://example.com/cb#access_token=2YotnFZFEjr1zCsicMWpAA
200 &state=xyz&token_type=example&expires_in=3600
201 """
202 fragment = urlparse.urlparse(uri).fragment
203 params = dict(urlparse.parse_qsl(fragment, keep_blank_values=True))
204
205 if "access_token" not in params:
206 raise MissingTokenException()
207
208 if "token_type" not in params:
209 raise MissingTokenTypeException()
210
211 if state and params.get("state", None) != state:
212 raise MismatchingStateException()
213
214 return params

Callers 1

token_from_fragmentMethod · 0.85

Calls 4

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…