我想发送Bearer
令牌作为授权标头,它正在postman
上运行,但是当我在模拟器上尝试时,我得到了403响应代码,Json
解析器volley
是我用来轻松发送请求的帮助程序类。
token=sharedPrefHelper.getSharedPreferenceString(getActivity(),"token","");
Toast.makeText(getActivity(), token, Toast.LENGTH_SHORT).show();
Log.i("gettoken",token+"zoz");
userIdRequest =new JsonParserVolley(getActivity());
userIdRequest.addHeader("Authorization","Bearer "+token);
userIdRequest.executeRequest(Request.Method.GET,
"https://taqoh.com/wum/wp-json/wp/v2/users/me"
, new VolleyCallback() {
@Override
public void notifySuccess(String response) {
Log.i("success",response);
//get the user id
}
@Override
public void notifyError(VolleyError error) {
Log.i("error",error.toString());
}
});