Skip to content

Instantly share code, notes, and snippets.

@vrutkovs
Created March 8, 2016 13:25
Show Gist options
  • Select an option

  • Save vrutkovs/dc1403fd4b7688caf685 to your computer and use it in GitHub Desktop.

Select an option

Save vrutkovs/dc1403fd4b7688caf685 to your computer and use it in GitHub Desktop.
python mock_jsons.py *[mock_jsons_py]
https://10.3.9.133:8443/oauth/authorize?client_id=openshift-challenging-client&response_type=token
----
You have reached this page by following a redirect Location header from an OAuth authorize request.
If a response_type=token parameter was passed to the /authorize endpoint, that requested an
"Implicit Grant" OAuth flow (see https://tools.ietf.org/html/rfc6749#section-4.2).
That flow requires the access token to be returned in the fragment portion of a redirect header.
Rather than following the redirect here, you can obtain the access token from the Location header
(see https://tools.ietf.org/html/rfc6749#section-4.2.2):
1. Parse the URL in the Location header and extract the fragment portion
2. Parse the fragment using the "application/x-www-form-urlencoded" format
3. The access_token parameter contains the granted OAuth access token
----
Traceback (most recent call last):
File "mock_jsons.py", line 81, in <module>
access_token = get_access_token("authorize")
File "mock_jsons.py", line 77, in get_access_token
output = request_and_save_output_to(url, prefix, with_auth=True)
File "mock_jsons.py", line 63, in request_and_save_output_to
content = json.dumps(r.json(), indent=4, separators=(',', ': '))
File "build/bdist.linux-x86_64/egg/osbs/http.py", line 379, in json
File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment