gpt4 book ai didi

curl - 通过 cURL 获取访问 token

转载 作者:行者123 更新时间:2023-12-01 06:22:08 25 4
gpt4 key购买 nike

简单的问题:

为什么以下代码有效......(它返回访问 token 就好了)

curl --data "grant_type=client_credentials&client_id=synchronization_tool&client_secret=8f6a6e73-66ca-4f8f-1234-ab909147f1cf" http://localhost:8080/auth/realms/master/protocol/openid-connect/token 

而这个没有?
curl -d  '{"grant_type":"client_credentials","client_secret":"8f6a6e73-66ca-4f8f-1234-ab909147f1cf","client_id":"synchronization_tool"}' http://localhost:8080/auth/realms/master/protocol/openid-connect/token -H "Content-Type: application/json"

它给了我:
"error":"invalid_request","error_description":"Missing form parameter: grant_type"}

他们不应该是两个完全相似的请求吗?

最佳答案

curl -d 'client_id=xxx' -d 'username=xxx' -d 'password=xxx' -d 'grant_type=password' 'http://localhost:8080/auth/realms/YOUR_REALM_NAME/protocol/openid-connect/token' | python -m json.tool

这对我有用,它会给你 access_tokensession_token

关于curl - 通过 cURL 获取访问 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50256433/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com