Reputation:
I want to create an app which will locate an Scooters. I am using Bird(Scooter) api. I got an Auth token, but when I want to send request with GET method, with headers, it returns me response code 401
, but auth token is not null. Please help me. Api Documentation
My request interface
public interface ApiCallsInterface {
@Headers({
"Device-id:43ba174c-11f4-4918-9fcc-6d785cfc256e"
,"Platform:android","Content-type:application/json"
})
@POST("/user/login")
Call<AuthResponseClass> getAuthToken(@Body Map<String, String> params);
@Headers({
"Device-id:43ba174c-11f4-4918-9fcc-6d785cfc256e",
"App-Version:3.0.5"
})
@GET("/bird/nearby?latitude=37.77184&longitude=-122.40910&radius=1000")
Call<BirdResponse> getBirds(@Header("Authorization") String token, @Header("Location") Map<String, String> params);}
How I send request
Map<String, String> requestParams = new HashMap<>();
requestParams.put("latitude",lat);
requestParams.put("longitude",lng);
requestParams.put("altitude","500");
requestParams.put("accuracy","100");
requestParams.put("speed","-1");
requestParams.put("heading","-1");
apiCallsInterface.getBirds(AUTH_TOKEN,requestParams).enqueue(new Callback<BirdResponse>() {
@Override
public void onResponse(Call<BirdResponse> call, Response<BirdResponse> response) {
Log.d(TAG,"" + response.code());
}
@Override
public void onFailure(Call<BirdResponse> call, Throwable t) {
}
});
Upvotes: 1
Views: 393
Reputation: 634
401 The request requires user authentication
Not adding the header properly here is the guide to generate header properly https://github.com/ubahnverleih/WoBike/blob/master/Bird.md
Upvotes: 0
Reputation: 131
Be sure to append "Bird " before your token as in your api documentation.
Upvotes: 2