【发布时间】:2021-11-19 18:34:48
【问题描述】:
我有下一个文档:
要创建帐户访问同意,您需要通过 识别您的应用程序的访问令牌:只需替换 CLIENT_ID 和 CLIENT_SECRET 在下面的 curl 中检索一个有效的:
curl -k -X POST \
https://mandarine.sai.com/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&scope=accounts'
回复:
HTTP/1.1 200
status: 200
content-type: application/json; charset=utf-8
{
"token_type": "Bearer",
"access_token": "Ci5A6huK2OD0d6...kVwLE9FuHwHGCf6xo5",
"expires_in": 7200,
"scope": "accounts"
}
所以我尝试在我的 ApiInterface 中进行下一步:
@Headers(
"Accept: application/json",
"Content-Type: application/x-www-form-urlencoded"
)
@POST("/token")
suspend fun requestToken(
@Query("client_ id") clientId: String,
@Query("client_secret") clientSecret: String
): AccessTokenResponse
但我不确定我是否为我的请求正确填写了data,即不清楚我仍应将client_credentials 和scope 放在哪里
【问题讨论】:
标签: android post request retrofit