Have you not looked at using the built in Authentication mechanisms that Android Annotations provides? Like Basic Auth or OAuth? This might be a cleaner solution.
https://github.com/excilys/androidannotations/wiki/Authenticated-Rest-Client
I have used the Basic Auth options - https://github.com/excilys/androidannotations/wiki/Rest%20API
You just need to add a method to your interface:
void setHttpBasicAuth(String username, String password);
Then call that before making the API call. There should be a similar option for OAuth.
EDIT: You can create a Login POJO to POST to your API:
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({
"name",
"password"
})
public class Login{
@JsonProperty("name")
private String name;
@JsonProperty("password")
private String password;
}
and then in your API Interface you can do the following:
@Post("user/login")
public APIKey login(Login credentials);
This will then POST your data to the /user/login method. You might need to add an interceptor depending on what kind of data you wish to parse ie converters = { MappingJacksonHttpMessageConverter.class }
etc.