【发布时间】:2017-11-30 17:24:12
【问题描述】:
我正在使用 rest 使用 API 密钥向 Bluemix 验证用户。我还想实现用户名和密码认证。
def auth(self):
self.log.debug('Authenticating to CloudFoundry')
url = self.info['authorization_endpoint'] + '/oauth/token'
headers = {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
'Accept': 'application/x-www-form-urlencoded;charset=utf-8',
'Authorization': 'Basic Y2Y6'
}
if self.api_auth:
data = 'grant_type=password&username=apikey&password={}'.format(self.api_key)
elif self.userpass_auth:
data = 'grant_type=password&username={}&password={}'.format(self.username, self.password)
else:
raise ValueError()
# send request ...
但是,当我尝试使用用户名和密码发出请求时,我收到了响应:
{"error_description":"BMXLS0202E: You are using a federated user ID,
please use one time code to login with option --sso.","error":"unauthorized"}
所以我可以将我的用户发送到 SSO 网页以获取令牌,但是当他们拥有 SSO 令牌时我需要制作什么 REST api?或者,我是否使用与上面相同的 rest api,但提供不同的参数?
【问题讨论】: