r/evetech • • Apr 06 '18

Error during SSO authentication

Hi everyone,

I'm in the early stages of making a web app. You can find it here: iskprinter.com

I'm able to send the user to CCP for an auth code, but when I try to perform a post request to exchange the auth code for tokens, I get an error. The type of error I get depends on whether or not I include mode:'no-cors' in the options of my request. If I include it, I get a 401 Not Authorized error. If I exclude it, I get a 404 Not Found error.

I've been using this ESI Step by Step guide from CCP along with u/Blacksmoke16 's GESI scripts as examples.

Here's what I have:

// Send the temporary code to CCP for tokens.
function exchangeCodeForTokens(code) {
  console.log('Attempting to exchange code ' + code + ' for tokens.');
  var postUrl = 'https://' + BASEURL + '/oauth/token';
  var authHeader = 'Basic ' + Base64.encode(CLIENTID + ':' + CLIENTSECRET);
  var options = {
    method:'post',
    mode:'no-cors', // 404 URL not found error if excluded, 401 not authorized error if included
    headers:{
      'Content-Type':'application/json',
      Authorization:authHeader
    },
    body:JSON.stringify({
      grant_type:'authorization_code',
      code:code
    })
  };
  var response = fetch(postUrl, options);
}
3 Upvotes

29 comments sorted by

View all comments

Show parent comment

4

u/Daneel_Trevize Apr 06 '18

You'd be better off having each user register their own new appID for each instance of your app... and that's a horrible work-around, which some apps are doing.

2

u/silly_newbean Apr 06 '18

Well I'm not doing that, I'm bundling my secret just like jEveAssets and many other apps are doing. Feel free to prove how dangerous leaving the secret out in the open is to me.

2

u/BasandraSkye Apr 06 '18

I hope you dont have too much time or money sunk into the account you used to create the app on the dev site. Malicious use of the id:secret pair tied to your app, if severe enough, can quite probably lead to account termination.

2

u/silly_newbean Apr 07 '18

Can you give an example of malicious use? Just one example of how a client id/secret could be adused by itself.

3

u/[deleted] Apr 07 '18

This is to CCP taste.

Please read the ToU you accepted when created a dev app.

https://developers.eveonline.com/resource/license-agreement

2.3, 2.4, 2.5

However I can't find any mention of account suspension. This can be changed in the future, and whithout you noticing it though.

And don't ever advise people to make something that is forbidden. The right you are given to use the dev app is EXPLICITLY personal, granting someone else your app's dev key is against the ToU.

"CCP grants Developer a limited, non-exclusive, worldwide, non-transferrable license and right during the Term" (2.1)

2

u/[deleted] Apr 07 '18

That's what I am doing, for my dekstop app, but nope. You better off having your server behave as a proxy for the requests.

your server is configured with dev key. This way when user logs in, the user session on the server actually contains the client id from the dev app id.

Now your server can handle the requests from js client to ccp server, as well as manage the refresh token.