所需结果:获取URL-https://secure.tdameritrade.com/authCafe?code=123456789 ....
我正在尝试从下面列出的图像2中获取代码。它位于重定向URL中。我到处都是stackoverflow,但没有任何建议可以解决。我尝试了所有变化。如果有人可以提供帮助,将不胜感激
我当前的失败代码:
import requests
import json
request_session = requests.session()
url = 'https://auth.tdameritrade.com/auth?response_type=code&redirect_uri=https://secure.tdameritrade.com/authCafe&client_id=MOBI@AMER.OAUTHAP'
data = {'username':'MY_USERNAME', 'password': 'MY_PASSWORD'}
auth_reply = request_session.post(url, data=data)
#auth_reply = request_session.post(url, auth=('MY_USERNAME', 'MY_PASSWORD'))
#auth_reply2 = request_session.get(auth_reply.url)
#auth_reply = request_session.post(url, data=data)
print(auth_reply.history[0].url)
print(auth_reply.history)
print(request_session.get(auth_reply.url).url)
print(auth_reply.url)
我将根据发布/获取状态代码302或状态代码200