0

如何curl基本的gravitee am api?我试过简单的也不能吗?

curl -X POST http://localhost:8093/admin/token -H 'authorization: Basic base64(admin:adminadmin)'

curl -X POST http://localhost:8093/admin/token -H 'Authorization: Basic YWRtaW46YWRtaW5hZG1pbg=='

它说 404 未找到。结果如下:

*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8093 (#0)
> POST /admin/token HTTP/1.1
> Host: localhost:8093
> User-Agent: curl/7.58.0
> Accept: */*
> Authorization: Basic YWRtaW46YWRtaW5hZG1pbg==
> 
< HTTP/1.1 404 Not Found
< Cache-Control: must-revalidate,no-cache,no-store
< Content-Type: text/html;charset=iso-8859-1
< Content-Length: 0
< 
* Connection #0 to host localhost left intact
4

1 回答 1

1

首先,您必须请求访问令牌:

curl -X POST http://localhost:8093/management/auth/token -u admin:adminadmin

您应该收到此有效负载:

{"access_token":"eyJraWQiOiJkZWZ......TyJ37E","expires_at":"Mon Nov 29 15:06:12 CET 2021","token_type":"bearer"}

然后您可以使用此 access_token 请求访问管理 API。

curl -X GET http://localhost:8093/management/organizations/DEFAULT/environments/DEFAULT/domains/ -H'Authorization: Bearer eyJraWQiOiJkZWZ......TyJ37E'
于 2021-11-22T14:10:44.703 回答