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

Function parse_implicit_response

authlib/oauth2/rfc6749/parameters.py:154–207  ·  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

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

Callers 1

token_from_fragmentMethod · 0.85

Calls 4

getMethod · 0.45

Tested by

no test coverage detected