如何使用用户名和密码从 uaa 服务器获取安全令牌。你能给我一些工作示例,我可以使用 Python 和/或 Postman 来做以下三件事:1.登录。2.获取令牌。3. 验证令牌。这些 uaa API 文档中的端点不起作用: https ://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#verify-user-get-users-id-verify
问问题
2244 次
1 回答
1
Python:
import requests, json, jwt
client_auth = requests.auth.HTTPBasicAuth('app', 'appclientsecret')
url = 'http://localhost:8080/uaa/oauth/token'
retval = requests.post(url=url, headers={'accept':'application/json'}, params= {'username':'marissa','password':'koala', 'grant_type':'password','client_id':'app'}, auth=client_auth)
decode_token(json.loads(retval.content.decode('utf-8'))['access_token'])
def decode_token(token):
print(token)
docoded = jwt.decode(token, verify=False)
print(decoded)
邮差:
POST /uaa/oauth/token? username=marissa&password=koala&client_id=app&grant_type=password HTTP/1.1
Host: localhost:8080
Content-Type: application/json
Authorization: Basic YXBwOmFwcGNsaWVudHNlY3JldA==
Cache-Control: no-cache
于 2015-03-07T23:36:03.027 回答