我使用排球向wordpress rest api发送请求,首先我将POST请求发送到/ wp-json / jwt-auth / v1 / token,当我尝试将令牌返回并存储在共享首选项中时,使用/ wp-json / jwt-auth / v1 / token / validate我得到403响应,当我向用户端点发送GET请求以获取当前用户ID时得到401响应
//my validate request
jsonParserVolley=new JsonParserVolley(MainActivity.this);
jsonParserVolley.addHeader("Authorization", "bearer " +token);
jsonParserVolley.executeRequest(Request.Method.POST,
"https://taqoh.com/wum/wp-json/jwt-auth/v1/token/validate"
, new VolleyCallback() {
@Override
public void notifySuccess(String response) {
Log.i("error",response);
}
@Override
public void notifyError(VolleyError error) {
Log.i("error",error.toString());
}
});
//my GET current user request
jsonParserVolley=new JsonParserVolley(MainActivity.this);
jsonParserVolley.addHeader("Authorization", "bearer " +token);
jsonParserVolley.executeRequest(Request.Method.GET,
"https://taqoh.com/wum/wp-json/wp/v2/users/me"
, new VolleyCallback() {
@Override
public void notifySuccess(String response) {
Log.i("error",response);
}
@Override
public void notifyError(VolleyError error) {
Log.i("error",error.toString());
}
});