我正在与Bluemix的CF API进行接口。我使用以下方法对OAuth端点进行身份验证:
oauth_endpoint = 'https://login.ng.bluemix.net/UAALoginServerWAR/oauth/token'
http_headers = {
'Authorization': 'Basic Y2Y6'
}
http_payload = {
'grant_type': 'password',
'username': user,
'password': pw
}
response = requests.post(oauth_endpoint, data=http_payload, headers=http_headers)
results = response.json()
authorization = results['token_type'] + ' ' + results['access_token']
authorized_headers = {
'Authorization': authorization
}然后刷新令牌:
http_refresh_payload = {
'grant_type': 'refresh_token',
'refresh_token': results['refresh_token']
}
response = requests.post(oauth_endpoint, data=http_refresh_payload, headers=http_headers)
results = response.json()
authorization = results['token_type'] + ' ' + results['access_token']
authorized_headers = {
'Authorization': authorization
}这些代币的有效期比我想要的要长。如何指定较短的过期时间?
发布于 2017-08-25 17:07:39
虽然我还无法弄清楚如何在oauth令牌上设置过期时间,但我还是能够用另一种方法来解决我的需求。这个post有了答案。也就是说,我在使Flask会话对象永久化之后设置了它的到期时间。
发布于 2017-08-24 16:45:26
Bluemix登录oauth令牌在1天内到期。您可以在某个时候使用刷新令牌。
https://stackoverflow.com/questions/45866711
复制相似问题