我怎样才能形成正确的查询?
How can I form a correct query?
我有下一个文档:
To create an account-access-consent, you'll need to pass an
access-token identifying your App: simply replace CLIENT_ID and
CLIENT_SECRET in the curl below to retrieve a valid one:
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
对于这个请求,需要编写如下请求:
@Headers(
"Accept: application/json",
"Content-Type: application/x-www-form-urlencoded"
)
@POST("/token")
suspend fun requestToken(
@Query("grant_type") grantType: String,
@Query("client_id") clientId: String,
@Query("client_secret") clientSecret: String,
@Query("scope") scope: String,
): AccessTokenResponse
我有下一个文档:
To create an account-access-consent, you'll need to pass an access-token identifying your App: simply replace CLIENT_ID and CLIENT_SECRET in the curl below to retrieve a valid one:
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
对于这个请求,需要编写如下请求:
@Headers(
"Accept: application/json",
"Content-Type: application/x-www-form-urlencoded"
)
@POST("/token")
suspend fun requestToken(
@Query("grant_type") grantType: String,
@Query("client_id") clientId: String,
@Query("client_secret") clientSecret: String,
@Query("scope") scope: String,
): AccessTokenResponse