[Tutor] Help : Response Headers Location

Motka Blank motka22 at gmail.com
Tue Dec 17 18:55:07 EST 2019


Hello all,
I am testing implicit grant flow, directly call to
example:
oauthurl = https://xxx.com? response_type=token&response_uri=
http://127.0.0.1:5000/&client_id=tester-grants

If I put above url in browser, it goes to login page and I put username,
password and submit the form, next page ( redirect uri) showed up with
access_token

http://127.0.0.1:5000/#access_token=abcdxyz

Question:
How can I get this access_token from backend python code.?
( I cannot use front end code, just use backend).
I have tried several stuff and I did not get success yet.
(1) I tried selenium webdriver:

    driver = webdriver.PhantomJS(executable_path='/usr/local/bin/phantomjs'
)
driver.get(oauthurl)
username_field = driver.find_element_by_name('pf.username')
username_field.send_keys(username)
password_field = driver.find_element_by_name('pf.pass')
password_field.send_keys(password)

submit_button = driver.find_element_by_id('login-button')
submit_button.submit()
time.sleep(20)
current_url = driver.current_url is showing oauthurl and it did not change.
I want to get redirect_uri with #access_token. If I get url including
access_token, I can split access_tikne from url.
But now I could not get this redirect url and I am struck with this.
Please help me what python library I should use or sample of code that can
get redirect uri would be very helpful.
When I got http://127.0.01:5000/#access_token=abcdxyz, in inspect, network -
I saw the access_token as a part of response headers Location.
Please share me if you have that kind of experience. I have been working on
that for a week now.

Thanks in advance,

Motka


More information about the Tutor mailing list