【发布时间】:2022-01-16 19:31:14
【问题描述】:
我有以下 Android 代码
@POST("/api/oauth/token") Call<Token> login(
@Query("client_id") String clientId,
@Query("client_secret") String clientSecret,
@Query("redirect_uri") String redirectUrl,
@Body() AuthBody authBody
)
import com.google.gson.annotations.SerializedName
data class AuthBody(
@SerializedName("username") var username: String?,
@SerializedName("password") var password: String?,
@SerializedName("grant_type") var grantType: String = "password"
)
对于发送请求,他们使用
import retrofit2.Call;
此代码用于从后端服务器获取访问令牌。我想把它转换成Curl命令,这样我就可以在不运行这段代码的情况下发送请求。
到目前为止我所拥有的是
curl "https://example.com/api/oauth/token?client_id={client_id}&client_secret={client_secret}&redirect_uri={redirect_uri}" --data '{"username":"{my-username}","password":"{my-password}","grant_type":"password"}'
但是运行时,服务器响应是
{"error":"invalid_request","error_description":"translation missing: en.doorkeeper.errors.messages.invalid_request.missing_param"}
我不知道我在这里缺少什么,请帮助我。
【问题讨论】: