如何从服务器获取标头?改造2

时间:2017-06-27 17:11:49

标签: android header retrofit2

当我登录到我的服务器时,我应该使用" x-auth-token"但我不知道怎么做?

在Java中它只是:

token = urlConnection.getHeaderField(" x-auth-token");

我已经尝试过了:

LoginService loginService = ServiceGenerator.createService(LoginService.class,loginEmail,loginPassword);
                Call<User> call = loginService.basicLogin();
                call.enqueue(new Callback<User>() {


                    @Override
                    public void onResponse(Call<User> call, Response<User> response) {


                        okhttp3.Headers headers = response.headers();
                        String token = response.headers().get("x-auth-token");
                        Log.e(LOG_TAG, "My token is" + token);



                            Toast.makeText(getApplicationContext(),"You have been logged", Toast.LENGTH_SHORT).show();

之后我得到了回复,我的x-auth-token = null;

0 个答案:

没有答案