【发布时间】:2017-08-26 01:07:39
【问题描述】:
我正在与 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
}
这些令牌的到期时间比我想要的要长。如何指定更短的到期时间?
【问题讨论】:
标签: python oauth ibm-cloud cloud-foundry