These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

Auth'd CREST and non web applications

First post
Author
Cryten Jones
Advantage Inc
#1 - 2015-02-09 12:10:03 UTC
Hi Devs,

I am wanting to use CREST to get some of the market data that is behind the auth'd part of the API but I am building a 'fat' application rather than a web based one.

All the information I can find on the auth process sees to point to the fact that I have to use a website (for the call back)... Is this the case or can I just ignore that part of the request if I don't want to be called back?


Thanks in advance.

Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#2 - 2015-02-09 18:05:08 UTC
You have to have a callback, so your application can get the tokens it needs to be able to auth.

Exactly how you do this can be flexible.


  • Embed a web browser: This is generally a bad idea, unless it's just for your own use. Training users to type their details into your application is a very very bad plan.
  • Have a small web app that just does the auth, and presents the refresh token, which you can put into your app to get an access token at will. Not good for lots of users, but it's workable.
  • have a webapp to do the auth. send your users to it with a specific token, which you have your app poll for, so it can get the refresh token
  • Embed a webserver and use that for the callback. (they click to log in, it sends them to their regular browser to auth, and your callback is http://localhost:34535/, which is where your clients web server is running.)
  • have a custom uri scheme, which fires up another app which hands the auth details to your main app, over a socket connection. Registering the uri scheme is a bit of a pita, but it works. This is probably the best option, tied with the webserver one. It's closest to how you'd do it on mobile.

Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter

Cryten Jones
Advantage Inc
#3 - 2015-02-09 22:46:23 UTC
Thanks Steve, really appreciate you taking the time.

So this app is a one off that I will be using my self. It has a number of accounts to access but only me as a user.

I am using VBA (or C# classes I write and put in to access) so if I am reading this right I am screwed right?

-CJ
Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#4 - 2015-02-10 00:38:16 UTC
VBA's handling for json is subpar, so it's less than good.

You're entirely able to do it though. The refresh token route is probably the one to go down. You can use something like Postman http://www.getpostman.com/ to do the initial step to generate the refresh token, store that in your application, then go from there.

Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter

Pete Butcher
The Scope
Gallente Federation
#5 - 2015-02-10 05:34:53 UTC
In Evernus I offer two ways of doing auth - by internal and external browser. The user can choose which method he prefers. Using the internal browser guarantees that everything will work on pretty much every system with any configuration, but it presents a trust issue for the users. Using the external browser moves the trust issue onto it, so the application becomes more trustworthy, but the user experience is worse because of switching between apps and you have no control of the process.
The way to handle external browser sounds easy in theory like Steve said, but it's more problematic in practice. Custom scheme will require you to promote the privileges to register it (and you need to validate it every time), which makes the app useless in most corporate environments, for example, or when current user simply doesn't have admin privileges. Local server has a similar problem - the user needs to have rights to open a port, which again might be not possible due to system security policies or firewall. And if you decide to make a multiplatform app, things get even more complicated.
In the end you have to think what environments you're targeting and choose the best method.

http://evernus.com - the ultimate multiplatform EVE trade tool + nullsec Alliance Market tool

Cryten Jones
Advantage Inc
#6 - 2015-02-10 13:34:35 UTC
Thanks both, much appreciated.

By the way, is there some secret repository of documentation on CREST? even the basics of how to talk to it would help... the auth part I mean here, the public is clear enough

-CJ
Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#7 - 2015-02-10 17:33:43 UTC
Afraid not as such.

The Auth portion is pretty much vanilla OAUTH2

The endpoints currently available are pretty much just 'GET the endpoint, with an auth header'. Except for the market order ones, where you have to pass in a typeid href as a parameter.

Foxfour is working up some documentation, which will be available in json. https://www.fuzzwork.co.uk/crestDocumentation.php is hooked up to dev version of it.


The key, in general, is not to hard code any url except the base (https://crest-tq.eveonline.com for TQ), and derive /all/ other hrefs from that.

Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter

Cryten Jones
Advantage Inc
#8 - 2015-02-11 00:18:42 UTC
So using the www.getpostman.com tool...

Auth URL = https://login.eveonline.com/oauth/authorize/

Auth Token = ????

ClientID = From the App registration

Client Secret = From App Registration

Scope = publicData



So what's the Auth Token and where do I put the state value ?


Sorry to be a pita :-)

-CJ

Ortho Loess
Escalated.
OnlyFleets.
#9 - 2015-02-11 00:57:28 UTC
For the basic oauth2 flow, there is a fairly good walkthrough on the dev site.

Subject to some things which are now out of date:

- Tokens are now valid for 20 mins, not 5.
- That guide states that refresh token is always null, it does now return one and this can be used to get a new auth token at any time (no expiry). (no docs on this afaik, it's standard oauth2 stuff though, so google is your friend)
- There is now one scope available to request "publicData" - only used for market orders at this time

There is other info, but it's spread around posts in this forum, often on page 8 of a long thread or similar. Hence the other thread about documentation!
Cryten Jones
Advantage Inc
#10 - 2015-02-12 16:01:53 UTC  |  Edited by: Cryten Jones
So thanks to you guys I am 99% of the way there...

I have Authenticated and got my refresh key and can access the API while the main token is still valid..

Can someone tell me the exact request structure when you are using the refresh token? I have tried reading the oauth stuff on google and reading Steve's PHP CREST implementation but as I am only a hobby coder I can't follow it all well enough to work out what's going on...

Where I am now is this:-

Make a request to https://crest-tq.eveonline.com/types (for example)

Headers:

Authorization = Basic (clientID):(secret)
grant_type = refresh_token (refresh_Token)


Obviously the () are place holders...


What am I doing wrong ?

Thanks
Pete Butcher
The Scope
Gallente Federation
#11 - 2015-02-12 16:25:16 UTC
Cryten Jones wrote:
So thanks to you guys I am 99% of the way there...

I have Authenticated and got my refresh key and can access the API while the main token is still valid..

Can someone tell me the exact request structure when you are using the refresh token? I have tried reading the oauth stuff on google and reading Steve's PHP CREST implementation but as I am only a hobby coder I can't follow it all well enough to work out what's going on...

Where I am now is this:-

Make a request to https://crest-tq.eveonline.com/types (for example)

Headers:

Authorization = Basic (clientID):(secret)
grant_type = refresh_token (refresh_Token)


Obviously the () are place holders...


What am I doing wrong ?

Thanks


If you have the refresh token, you need to obtain the access token, which is then used to make other requests. Make a request to /oauth/token with grant_type=refresh_token&refresh_token=... as data and Authorization: Basic base64((clientID):(secret)) in the headers. You'll get the access token, which should be appended as Authorization header to other requests, as described on https://developers.eveonline.com/resource/single-sign-on .

http://evernus.com - the ultimate multiplatform EVE trade tool + nullsec Alliance Market tool

Hel O'Ween
Men On A Mission
#12 - 2015-02-13 08:35:11 UTC
Cryten Jones wrote:

I am using VBA (or C# classes I write and put in to access) so if I am reading this right I am screwed right?


I've posted this elsewhere already: from the little testing I did, the most-decent JSON parser for VBA I could dig up is http://www.codeproject.com/Articles/720368/VB-JSON-Parser-Improved-Performance

There's a lot more for C#, though.

EVEWalletAware - an offline wallet manager.

Cryten Jones
Advantage Inc
#13 - 2015-02-13 20:59:05 UTC
So just to compete the loop for other who come searching..

Using the json parser in the post above here, I was able the read the JSON in Dictionaries and move on from there.

Got the Authed Crest working also by using the google plugin mentioned above to setup the first authentication allowing access to a refresh token.

Happy to share the VBA for the Authentication if people want it ping me an eve mail




Thanks for all the support guys, much appreciated!


-CJ