【发布时间】:2019-05-05 10:51:38
【问题描述】:
在使用 Post 方法时在 Android 中我的 grant type 在缺失
我想从我的 post 方法中获取 access_token,但它显示 grant_type 缺失,因为在正文中我的 grant_type 是 client_credentials 所以我如何将 grant_type 添加到我的 url 以便我授予 access_token 权限
Request originalRequest = chain.request();
String credentials = authUserName + ":" + authPassword;
final String basic =Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
Request newRequest = chain.request().newBuilder().addHeader("Authorization","Basic " + basic).build();
return chain.proceed(newRequest);
我的apiInterface
@POST("token")
Call<ResponseBody> getToken();
}
我的日志报告
D/OkHttp: {"error":"invalid_request","error_description":"Missing grant type"}
Postman Post 方法截图
如何在我的代码中授予类型
【问题讨论】: