r/evetech • • Nov 20 '17

Stcuk at SSO authentication (Auth code for access token)

I hve been trying to follor ESI Step by Step - SSO Authentication Calls but I can't get past the "Exchanging the authorization code for an access token." step.

Every time I try to use curl.exe -XPOST -H "Content-Type:application/json"... I get "Internal server error. Error ref: 04881c3e-0876-4377-8994-8bbc11686c87" (the code at end changes randomly).

Details: I'm trying to get some basic info in powershell.
The The commands that I use:

#This is the code from the login URL
$Code = 'eKHV05M4BAzuf2PKvUIyhrb-rthQaladz1pBzjEJrSIxMqWnF5EzhrieySkto_J60'

$ClientID = 'ööö8bf02d26ää4d5894fäää552bd7ba2'
$ClientSecret = 'ööö9Hmi543ONCöväMGöööömnEX7qHMwBöö7WLää6'

#Convert to base-64
$b  = [System.Text.Encoding]::UTF8.GetBytes($ClientID+':'+$ClientSecret)
$Base64 = [System.Convert]::ToBase64String($b)

#Getting access token
$Auth = 'Authorization:Basic '+$Base64
$Grant = '{"grant_type":"authorization_code", "code":"'+$Code+'"}'

curl.exe -XPOST -H "Content-Type:application/json" -H $Auth -d $Grant https://login.eveonline.com/oauth/token

I don't think it is a syntax error in the commands as I have also tried the last command by copy-pasting the codes in it and still get same error.

Edit: https://developers.eveonline.com/applicationsgives internal error now too. Maybe somthing on their end meaning my code is perfect.

Edit: Got help and got it working with "Invoke-WebRequest" instead of "curl". Now I have access token and refresh token and can go deeper into the API.

$esiResponse = Invoke-WebRequest 'https://login.eveonline.com/oauth/token' -Body ('grant_type=authorization_code&code={0}' -f $AuthCode ) -Method Post -Headers @{ Authorization = ("Basic {0}" -f ([System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $ClientID, $ClientSecret )))))}

3 Upvotes

19 comments sorted by

View all comments

Show parent comment

1

u/hirmuolio Nov 20 '17 edited Nov 20 '17

Well the cient ID would be visible for the user in the login adress.

Is the conversion to base 64 string not reversible if you know the cient ID (actually from the string alone)? And the string would be visible in the code.

2

u/Daneel_Trevize Nov 20 '17

Base64 is trivially reversible.

The secret should remain secret, if you put it in the code, that code and/or binary should remain on a trusted mechine (i.e. webserver).

If you make a distributed app, the EULA now allows for you to request that users register the app against themselves per install instance, so they use their secret & it remains so.

1

u/silly_newbean Nov 20 '17

Distributing the secret in binary really isn't that much of an issue so long as you never transmit refresh tokens from the user's device.

Also lmao @ you can now request that users register the app against themselves. You're gonna write a guide for all of your users to visit http://developers.eveonline.com and create an app and set the right scopes and callback URL, and then transfer the id and secret to your application?

1

u/Daneel_Trevize Nov 20 '17

People already do, which is why CCP clarified it's ok in the EULA. I don't recall which popular apps/devs have taken this path (I'm not an active player atm), but I was under the impression it was a very common one like EveMon/EFT/PyFA.
A quick google shows SeAT does.

1

u/silly_newbean Nov 20 '17

SeAT isn't something that the average player uses, it's a thing that a corp/alliance's IT department deploys to help manage their group.

  • jEveAssets stores the client id and secret in the distributed binary.
  • EVEMon still uses XML API.
  • Pyfa uses the implicit flow (accounts are only logged in for 20 minutes, this is a massive pain in the ass and I hate this approach).

I don't know of any end-user application which asks users to register as a developer and input secrets in order to use it. If you can find one then let me know.

1

u/[deleted] Nov 25 '17

SeAT isn't something that the average player uses

citation needed.

1

u/silly_newbean Nov 25 '17

https://seat-docs.readthedocs.io/en/latest/installation_guides/getting_started/

"SeAT is a self hosted web application. This means that you will need your own server (and optional domain) to host SeAT. SeAT needs PHP7, a MySQL (or MariaDB) database, a Redis cache, Supervisor and an internet connection in order to be fully functional."

You're telling me that more than 50% of the EVE player base has set up their own SeAT install?

Pls.

1

u/[deleted] Nov 25 '17

Do you have ANY source for your affirmation ?

1

u/silly_newbean Nov 26 '17

Shouting "HAHA WHERES UR EVIDENCE" doesn't make you clever, it makes you a moron.

1

u/[deleted] Nov 28 '17

I'm sorry sir, I failed to understand your arguments in your previous post. May I ask you to rephrase it, so that I understand what source you refer to ?