0

I'm trying to get the code from the Authorization Code Grant, but I just don't understand how to get the redirect link containing the code. My code looks like this:

params = {"response_type" : "code",
          "client_id" : "my_client_id",
          "state" : secrets.token_urlsafe(10),
          "redirect_uri" : "http://localhost/myapp",
          "client_secret" : "my_client_secret"}
r = requests.get(app_conf["AuthorizationEndpoint"], data = params)
print(r.url)
x = requests.post(r.url, json = {"field_userid" : "my_user", "field_password" : "my_pass"}, allow_redirects = True)
print(x.url)
print(x.history[0].headers["Location"])

The result of the first print is this:

https://live.logonvalidation.net:443/login/?requestId=<server_generated_request_id>&mode=oauth

After that I authenticate and the second print result is:

https://live.logonvalidation.net/ForwardOAuth/<same_request_id>

The third print result, which I wrote as it was suggested here is the same as the second.

What I need is getting the redirect_url with the code as argument, example: http://localhost/myapp?code=<code_needed>. How do I do that?

Lorenzo
  • 75
  • 8

0 Answers0