I have next documentation:
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'
Response:
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"
}
So i tried to next in my 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
But I'm not sure that I'm filling in the data
correctly for my request, namely, it's not clear where I should still place client_credentials
and scope
CodePudding user response:
For this request, it was necessary to write the following request:
@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