I am using a combination of the Robot request library, Python requests library and the Python requests_oauthlib library for the testing of an OAuth2 project.
I wonder if there is an easy way to grab the auth code (without string indexing) so I can use it in generating a token
So for example, I have the response header (from logging in):
{'location': 'http://127.0.0.1:19333/callback?code=clT17dFPedsgdfgsSFGDF%3D%3D&state=random%2F', 'content-length': '0', 'date': 'Fri, 09 Oct 2020 11:20:52 GMT'}
which I got by doing response.header
Is there some way I can just get the clT17dFPedsgdfgsSFGDF%3D%3D
by doing something like request.auth_code
Use the
Urllib.parse
. Theparse_qs
function returns a dictionary of key-value pairs whereas theparse_qsl
function returns a list of (key, value) tuples.Output -
For more details on URL encoding