M
M
Michael2018-03-18 21:13:13
Java
Michael, 2018-03-18 21:13:13

Retrofit correctly how to log in header?

there is a site data.gov.spb.ru/developers
need to get a list of data from there
how to organize the correct authorization using retrofit?
the site says this: The
token is passed to the HTTP Header in the format “Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b”
What I got:

@GET("/api/v1/datasets")
    @Headers("Authorization: Token e0fdb92b7fcbbf9241a9a8f22b592b3d83544ffa")
    Call<List<PostModel>> getData(@Query("id")int count, @Query("name") String resourceName);

app crashes on startup

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-03-22
@fuliozor

You can pass the token like this:

@GET("/api/v1/datasets")
 Call<List<PostModel>> getData(@Query("id")int count, @Query("name") String resourceName, @Header("Authorization") String token);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question