Retrofit add header with token and id

前端 未结 2 1459
醉梦人生
醉梦人生 2021-02-04 17:14

I have a problem with getting authenticated user. Before it I got token and user id. Now i need to get user from server using access token and id. I have header format

2条回答
  •  孤街浪徒
    2021-02-04 17:32

    Try to pass the header values via the method call:

    @GET("driver/v1/driver")
    Call getAuthorizedDriver(@Header("authorization") String token,
                                     @Header("driver_id") Integer id);
    

    You also wouldn't have to deal with this huge chunk of Interceptor code

提交回复
热议问题