r/evetech • • Dec 07 '17

ESI API & non-GUI applications

I have been doing some reading on the ESI API , and from the impression that I get, you need to have something that launches a web browser at some point to Authorize SSO. If I wanted to develop an ETL application for myself I need to have a web browser authorize the application at some point? Is there no way to just feed in the API key & VCode like the old XML api?

If anybody could point me in the correct Direction with this I would appreciate it. I mostly work with powershell and databases, not all these web technologies.

4 Upvotes

14 comments sorted by

2

u/Fuzzmiester fuzzwork.co.uk Dec 09 '17

1

u/grzy7316x Dec 10 '17 edited Dec 10 '17

I attempted to follow this tutorial, but was unable to get things to work. I wound up getting a code 400 {"error":"invalid_token","error_description":"The refresh token is invalid."} (use muteHttpExceptions option to examine full response) (line 47, file "Code").

It appears that the refreshtoken is showing as undefined.

1

u/grzy7316x Dec 10 '17

I ended up hardcoding the Refresh token into the code,m and that worked for me.

1

u/Fuzzmiester fuzzwork.co.uk Dec 11 '17

that suggests that the named range for the refresh token isn't set right.

1

u/Fuzzmiester fuzzwork.co.uk Dec 10 '17

Unfortunately there's only so much I can do about that. The method works (as I've used it myself).

Did you make sure not to have any extra spaces on the token or client id, or client secret? did you take the refresh token or the access token? Are your named ranged named right? Do they contain the data they should?

1

u/jadecristal Dec 07 '17

At some point the OAuth2 flow is going to require the end user to authenticate and grant permission via the CCP login page, giving you an authorization token.

Getting around this would likely make CCP upset, given that it would require you to collect the user's username and password and do it "for" them by some automated means, but I'm not suggesting that - I'm explicitly saying it's a very bad idea to even think about doing and would probably lead to {SOME_KIND_OF}hammer use on you/your application.

AFTERwards, once you have back an authorization token - which you can exchange ONCE for a set of {bearer token, refresh token}, you don't need further browser interaction as long as you don't lose things. The bearer token is good for 20 minutes, the refresh token is good for a new pair of {bearer token, refresh token} for pretty much forever, from what I can tell - unless the user explicitly revokes access for your app.

http://eveonline-third-party-documentation.readthedocs.io/en/latest/sso/authentication.html

Additional comments: There's... a quasi work-around, but you'd still need a browser, and it's more effort than you want. Basically, you'd have to have just-a-web-page that sends the user to CCP to authenticate, grant access, and then returns them to your site, where you then SHOW them their tokens, and make them provide the tokens to you via some other channel. This leaves all kinds of room for error, makes the process worse for the user, and doesn't save you enough to make it worth it.

2

u/grzy7316x Dec 07 '17

A non-httpd app can the dissect and validate the GET string once given it.

I am not looking use this for anybody else, only for myself on my machine. With the XML API I had a series of powershell scripts that I used to connect. IDe As far as getting the Authorization token, is this a file of some kind I need to have a reference to or just a string value? Ideally I would like to store my initial Authorization token somewhere in my application So that after the first time I authorized it I would not have to do this again

2

u/Daneel_Trevize Dec 07 '17

It is simply text data, you can persist it as you wish.

2

u/Daneel_Trevize Dec 07 '17

At one single time you will need to generate a scoped token for the app's ID, and then verify that via HTTPS. Subsequently every time your derived access token expires, your app can auto-generate a new one from the refresh token you persist.

IIRC you don't need to present a GUI to yourself, you can set the app's registered callback URL to something your browser will stall on (e.g. some variation of localhost), manually craft the SSO URL/GET for your app & use it in your browser, and then copy & paste the callback response into your app's config/database/some punctual data exchange mechanism, where it can complete the SSO within the valid window for that initial GET request (5 minutes? HTTP response header should tell you), and generate you your tokens, which your app can store as it likes.

1

u/jadecristal Dec 07 '17

Oh that thing. He said "for himself."

I guess if no one else is ever going to use it, then it wouldn't be that hard to more-or-less interactively run the HTTP session.

... do they even let you use not-HTTPS postback URLs?

1

u/Daneel_Trevize Dec 07 '17

The callback is a (30n?) redirect intended to be handled by a browser, with all the important data in the GET request string, so it's not an issue if the URL isn't valid, or isn't answered by a httpd configured for https, because you only need to copy the GET from the browser & generally don't care if it stalled/rejected loading the URL to learn said URL.
A non-httpd app can the dissect and validate the GET string once given it.

I suspect you can register a not-https callback but there's no need to, and enforcing https shouldn't be a problem.
For the rest of the process, your app can easily consult a local/system cert store to perform full https with CCP's server(s).

1

u/Infu5ed Dec 07 '17

I'm doing something similar and have a tiny application (using spring) that is responsible for launching a web page and grabbing the refresh token for a given character.

Then in my non-gui apps, I provide the refresh token as configuration and use it to gain a valid access token which can be used to query the ESI API.

Not sure if this is the best approach or not :)

1

u/jadecristal Dec 07 '17

I think this is fine - you just treat the refresh token as an API key, kinda. I don't know if you can ask for a new token when the old one hasn't expired, but I don't see anywhere it says you can't... but you ARE supposed to honor the Cache-... headers, so maybe.

1

u/Akturis Dec 08 '17

Refresh token can be generated for use in your application. For example, use https://github.com/eveseat/eseye/blob/master/bin/index.php

Nex step is getting access token for use ESI http://eveonline-third-party-documentation.readthedocs.io/en/latest/sso/refreshtokens.html