# SSO Implementation JS -\> 404

**URL:** <https://forums.eveonline.com/t/sso-implementation-js-404/24808>\
**Category:** Third Party Developers\
**Created:** [September 15, 2017, 5:31pm UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808 "2017-09-15T17:31:16Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tanaka\_Seiko](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/tanaka_seiko/32/439667_2.png) [@Tanaka\_Seiko](https://forums.eveonline.com/u/Tanaka_Seiko)\
**Post date:** [September 15, 2017, 5:31pm UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/1 "2017-09-15T17:31:16Z")

</div>

Hi there,

I am currently looking at the SSO Implementation and I am stuck at a point, where I get the following error:

_Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin_

After reading and googling, I turned CURL off in my browser, which lead to the following error:

_Response for preflight has invalid HTTP status code 404_

I read through all the posts and stuff, but I do not realize, what is wrong here. Here is my JS:

```
state = getURLParameter('state');
code = getURLParameter('code');

clid = "clientid"; //off course these are set to my apps values
secr = "secret";

url = "https://login.eveonline.com/oauth/token";

var method = "POST";
var pcode = btoa(clid+":"+secr);
var heada = "Basic " + pcode;

```

var postData =  
{  
“grant\_type”:“authorization\_code”,  
“code”:code  
}

```
var async = true;
var request = new XMLHttpRequest();

Request.onload = function () {
  var status = request.status; 
  var data = request.responseText; 
}

request.open(method, url, async);
request.setRequestHeader("Authorization", heada);
request.setRequestHeader("Content-Type", "application/json");
request.setRequestHeader("Cache-Control","no-cache");
request.send(postData);

```

Anyone got any idea?

Many thanks in advance!

---

<div class="post-metadata">

**Author:** ![Steve\_Ronuken](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/steve_ronuken/32/373894_2.png) [@Steve\_Ronuken](https://forums.eveonline.com/u/Steve_Ronuken)\
**Post date:** [September 15, 2017, 8:18pm UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/2 "2017-09-15T20:18:58Z")

</div>

[https://www.fuzzwork.co.uk/market/viewer2/](https://www.fuzzwork.co.uk/market/viewer2/)

Try an implicit version, rather than the route you’re taking at the moment. for one, it means you’re not exposing your secret, which is somewhat iffy.

Downside: no refresh token.

---

<div class="post-metadata">

**Author:** ![Tanaka\_Seiko](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/tanaka_seiko/32/439667_2.png) [@Tanaka\_Seiko](https://forums.eveonline.com/u/Tanaka_Seiko)\
**Post date:** [September 15, 2017, 8:20pm UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/3 "2017-09-15T20:20:51Z")

</div>

Thanks Steve,

I looked at your code, but it has so many other functions, so I honestly did not get it 😉

So maybe if you post the relevant stuff with an explanantion would ne great…

Oh and by the way love your stuff, use it daily 😉

---

<div class="post-metadata">

**Author:** ![Steve\_Ronuken](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/steve_ronuken/32/373894_2.png) [@Steve\_Ronuken](https://forums.eveonline.com/u/Steve_Ronuken)\
**Post date:** [September 15, 2017, 8:26pm UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/4 "2017-09-15T20:26:38Z")

</div>

view-source:[https://www.fuzzwork.co.uk/market/viewer2/marketExplorer.js](https://www.fuzzwork.co.uk/market/viewer2/marketExplorer.js)

extractFromHash function

the other key bit is:

window.location = “[https://login.eveonline.com/oauth/authorize/](https://login.eveonline.com/oauth/authorize/)” +  
"?response\_type=token" +  
"&client\_id=" + clientId +  
"&scope=" + scopes +  
"&redirect\_uri=" + redirectUri +  
"&state=" + csrfToken;

the response\_type=token means that the token is returned as part of the url.

---

<div class="post-metadata">

**Author:** ![Tanaka\_Seiko](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/tanaka_seiko/32/439667_2.png) [@Tanaka\_Seiko](https://forums.eveonline.com/u/Tanaka_Seiko)\
**Post date:** [September 17, 2017, 11:54am UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/5 "2017-09-17T11:54:57Z")

</div>

Hi again,

thanks a lot, I will try it to understand it 😜

Cheers,

Tanaka

---

<div class="post-metadata">

**Author:** ![Tanaka\_Seiko](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/tanaka_seiko/32/439667_2.png) [@Tanaka\_Seiko](https://forums.eveonline.com/u/Tanaka_Seiko)\
**Post date:** [September 19, 2017, 9:20am UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/6 "2017-09-19T09:20:17Z")

</div>

Hey Steve,

works with your code. (as expected) Still I would love to get the other one working, so if anybody has an idea ?

Kind regards,

Tanaka

---

<div class="post-metadata">

**Author:** ![NickyYo](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/nickyyo/32/387668_2.png) [@NickyYo](https://forums.eveonline.com/u/NickyYo)\
**Post date:** [September 19, 2017, 9:55am UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/7 "2017-09-19T09:55:41Z")

</div>

Can you post your code as a gist on Github and I’ll give you feedback, cheers.

---

<div class="post-metadata">

**Author:** ![Tanaka\_Seiko](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/tanaka_seiko/32/439667_2.png) [@Tanaka\_Seiko](https://forums.eveonline.com/u/Tanaka_Seiko)\
**Post date:** [September 19, 2017, 12:24pm UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/8 "2017-09-19T12:24:13Z")

</div>

Thank you,

Code is upwards in the original post…

---

<div class="post-metadata">

**Author:** ![NickyYo](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/nickyyo/32/387668_2.png) [@NickyYo](https://forums.eveonline.com/u/NickyYo)\
**Post date:** [September 19, 2017, 12:27pm UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/9 "2017-09-19T12:27:41Z")

</div>

Fine, don’t take my help then… GIST is better because i can reply with proper formatted code in the GIST comments, anyway whatever…

---

<div class="post-metadata">

**Author:** ![Tanaka\_Seiko](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/tanaka_seiko/32/439667_2.png) [@Tanaka\_Seiko](https://forums.eveonline.com/u/Tanaka_Seiko)\
**Post date:** [September 19, 2017, 7:38pm UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/10 "2017-09-19T19:38:39Z")

</div>

Hahahaha,

once I try to get a charcter ID I get the same problem again also with the explicit method. I even completely copied your method, so it gets the same parameters, nothing.

I ddo not think they really want us to use this 😉

Any ideas ?

---

<div class="post-metadata">

**Author:** ![Tanaka\_Seiko](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/tanaka_seiko/32/439667_2.png) [@Tanaka\_Seiko](https://forums.eveonline.com/u/Tanaka_Seiko)\
**Post date:** [September 20, 2017, 8:38am UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/11 "2017-09-20T08:38:45Z")

</div>

Well it definitely seems to be a CORS issue. I wonder how I can get around it, cause in the CORS definition it says the server needs to have a setting like

_Access-Control-Allow-Origin: [http://mydomain.com](http://mydomain.com)_

I doubt, CCP will do this for everyone, so the concept behind this should be something else, which I am still missing, which for sure is my fault. I will completely redo the code and post again if it fails.

Inbetween, if there is someone who REALLY knows, I’ll pay 250M ISK for a working, commented and readable solution, just login using EVE SSO, get a token, get a character ID and retrieve something from the character.

Cheers,

Tanaka

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/blacksmoke16/32/376589_2.png) [@Blacksmoke16](https://forums.eveonline.com/u/Blacksmoke16)\
**Post date:** [September 20, 2017, 3:17pm UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/12 "2017-09-20T15:17:38Z")

</div>

This might be a bug? ESI endpoints should have `Access-Control-Allow-Origin: *`. Or at least pretty much all the ones i saw. However, im not sure if the SSO login URL should be included in that.

However this is an SSO issue so you’d have to talk to the mystical SSO team.

---

<div class="post-metadata">

**Author:** ![Tanaka\_Seiko](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/tanaka_seiko/32/439667_2.png) [@Tanaka\_Seiko](https://forums.eveonline.com/u/Tanaka_Seiko)\
**Post date:** [September 20, 2017, 7:41pm UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/13 "2017-09-20T19:41:33Z")

</div>

Wherever they are… Can I post a ticket to them anywhere?

Cheers,

Tanaka

---

<div class="post-metadata">

**Author:** ![Tanaka\_Seiko](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/tanaka_seiko/32/439667_2.png) [@Tanaka\_Seiko](https://forums.eveonline.com/u/Tanaka_Seiko)\
**Post date:** [October 5, 2017, 5:52pm UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/14 "2017-10-05T17:52:03Z")

</div>

Ok, after reading everything, I do not think this works correctly. So if there is anyone who actally managed to get a character ID within a browser session (not only a token token is easy using implicit) please let me know.

And it would be nice if CCP would get someone in just to make it clear. Is the Allow-Access-Origins header set or not?

I am still offering 250M ISK for a working solution using a webpage and js.

TYVM,

Tanaka

---

<div class="post-metadata">

**Author:** ![Steve\_Ronuken](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/steve_ronuken/32/373894_2.png) [@Steve\_Ronuken](https://forums.eveonline.com/u/Steve_Ronuken)\
**Post date:** [October 7, 2017, 1:27am UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/15 "2017-10-07T01:27:09Z")

</div>

There’s a verify endpoint for ESI which works just fine.

and: [https://evemail.fuzzwork.co.uk](https://evemail.fuzzwork.co.uk)

You need the character ID to be able to get someone’s mails 😃

---

<div class="post-metadata">

**Author:** ![Steve\_Ronuken](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/steve_ronuken/32/373894_2.png) [@Steve\_Ronuken](https://forums.eveonline.com/u/Steve_Ronuken)\
**Post date:** [October 7, 2017, 8:14pm UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/17 "2017-10-07T20:14:26Z")

</div>

Just to be clear: when I say ‘someone’s mails’, I mean the owner of the account who authed 😉

---

<div class="post-metadata">

**Author:** ![Tanaka\_Seiko](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/tanaka_seiko/32/439667_2.png) [@Tanaka\_Seiko](https://forums.eveonline.com/u/Tanaka_Seiko)\
**Post date:** [October 9, 2017, 10:34am UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/18 "2017-10-09T10:34:09Z")

</div>

Hello Steve,

it finally works, but I think for no reason. I did a GET request using $,ajax, while you are doing a $.jsonGET, which in my opinion in this case are the same. Doing getJSON worked for me, so I will not bother finding out the difference 😉

I sent you 250 M ISK (Proof: [https://i.imgur.com/HxDdBRJ.png](https://i.imgur.com/HxDdBRJ.png)) , as you provided a working solution and I am keeping my promise. Thanks again and you have my next CSM vote again!

Fly safe!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/eveonline/original/3X/4/1/41ec4921cbaca7a6f9ea556e7cc20018461eae5e.png) [@system](https://forums.eveonline.com/u/system)\
**Post date:** [January 7, 2018, 10:35am UTC](https://forums.eveonline.com/t/sso-implementation-js-404/24808/19 "2018-01-07T10:35:00Z")

</div>

Closed on January 7, 2018, 10:35am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
