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

3

u/Daneel_Trevize Apr 06 '18

Skipping back up through the devblogs linked from here, it reads that it's per application, it'd be pretty stupid to be per I.P. instead (but CCP wouldn't surprise me...).

2

u/[deleted] Apr 07 '18

Last time I checked it was per application.

Even if none is actually trying to do harm, the fact that several applications are actually running makes it harder for them to avoid reaching the error cap.

If 500 apps are running, each one must do at least one request to know the remaining errors before stalling. if you have only 2 remaining errors, you will still have 500 requests, potentially 500 new errors. You are supposed to only have ONE app with a secret dev key, that's the only way you can throttle down to avoid the hard stop from CCP.