我正在使用 CF API RESTful 服务。尝试使用https://login..../oauth/token Web 方法从 Cloud Foundry 的 UAA API 获取访问令牌。
我已经验证标题和正文内容是正确的,但调用 api 总是返回 400 错误代码,消息缺少授权类型。
我已经在 Objective-C、Swift 和现在的 Python 中实现了这个调用。所有测试都返回相同的结果。这是我在 Python 中的代码示例:
import json
import requests
import urllib
params = {"grant_type": "password",
"passcode": "xxx"
}
url = "https://login.system.aws-usw02-pr.ice.predix.io/oauth/token"
headers = {"Authorization": "Basic Y2Y6", "Content-Type": "application/json", "Accept": "application/x-www-form-urlencoded"}
encodeParams = urllib.parse.urlencode(params)
response = requests.post(url, headers=headers, data=encodeParams)
rjson = response.json()
print(rjson)
每次运行此程序时,我都会收到响应错误无效请求,缺少授权类型
任何帮助将不胜感激。