如何从 CloudFoundry 获取 OAuth 令牌 [英] How to get OAuth token from CloudFoundry
问题描述
我想使用 curl 从云代工厂获取数据,但我无法进行身份验证(针对 CF 的 oauth).拜托,有人可以指出我并举例说明如何获得 oauth 令牌吗?我想使用登录名和密码.
I want to get data from cloud foundry using curl, but I'm not able to authenticate (oauth against CF). Please, could someone point me to and example how to get oauth token? I want to use login name and password.
谢谢
推荐答案
这不是您所要求的,但如果安装了最近的 cf cli,您可以正常登录,然后使用 cf curl
命令来运行原始请求.
This isn't exactly what you asked for, but if a recent cf cli is installed you can login as normal and then use the cf curl
command to run raw requests.
例如
$ cf login (or cf auth for non-interactive login)
$ cf curl /v2/spaces/c4e73f65-4dbc-47dc-9d21-e8c566c40587/summary
要使用实际的 curl
,再次使用 cf cli,使用以下命令检索承载令牌:
To use actual curl
, again using the cf cli, retrieve the bearer token with:
$ cf oauth-token
然后使用授权标头执行 curl 命令:
Then execute your curl command with an Authorization header:
$ curl --header 'Authorization: bearer ...' https://api.example.com/v2/spaces/c4e73f65-4dbc-47dc-9d21-e8c566c40587/summary
这篇关于如何从 CloudFoundry 获取 OAuth 令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!