如何使用齐射发送承载令牌作为授权标头

时间:2019-07-24 16:17:44

标签: java android authorization android-volley bearer-token

我想发送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());
                            }
                        });

0 个答案:

没有答案