These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

[Android] Trying to get access token after successful login

Author
Selaria Unbertable
Bellator in Capsulam
#1 - 2017-07-16 11:49:20 UTC
Hello fellow code monkeys :)

I'm currently trying to build an android app that allows me to set waypoints ingame. I'm using the evanova example found on bitbucket (https://bitbucket.org/evanova/eve-sso-android), which provided a good start. The login itself is working, but I'm currently stucked with retrieving the access code as described in this part of the documentation.

All I'm getting so far is an error 400: Bad Request - Invalid Header / HTTP Error 400. The request has an invalid header name.

This is the code in question:


    json = new HashMap<>(); // the map is correctly initialized, the forum doesn't work with the actual code
    json.put("grant_type", "authorization_code");
    json.put("code", credential.getAccessToken());
    JsonHttpContent content = new JsonHttpContent(new JacksonFactory(), json);
    HttpRequest request = factory.buildPostRequest(new GenericUrl("https://login.eveonline.com/oauth/token"), content);
    String auth = OAuthPreferences.getClientID() + ":" + OAuthPreferences.getClientSecret();
    request.getHeaders().setAuthorization("Basic " + Base64.encodeToString(auth.getBytes(), Base64.NO_WRAP));
    request.getHeaders().setContentType("application/json; charset=utf-8");
    response = request.execute();


I'm not sure what I'm missing, any help is appreciated.

o/
Selaria Unbertable
Bellator in Capsulam
#2 - 2017-07-16 15:33:02 UTC
Never mind, found the problem. Turns out the access token was already retrieved Ugh...

I'm rewriting the code to work with scribejava, seems easier to do requests with that one.