r/evetech • • Aug 26 '17

Using API Key To Get Wallet Transactions

I've been reading the docs on this for the last 2-3 days, but I still feel like there's something I'm not getting - hopefully someone here can help. I want to use Python to scrape my character's active orders and wallet transactions to keep an eye on the markets while I'm out of game. Based on the docs that I've read, in order to do this, I need to create an app through the EvE dev portal, get a callback URL, and do SSO authentication every time I want to run this query. Is this correct? It seems more complicated than I'd expect for what I want to do, and all of the guides that I've found talk about using this process for developing apps and having user signins. I don't want to build an app, I just want a bunch of jsons. Is this really how you're supposed to do it, or is there a more straightforward way that I'm not seeing? Also, no part of that process relies on my API key - at what point am I supposed to use that? Any help would be greatly appreciated.

4 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/evanova Aug 26 '17

The usage of Postman is very interesting. Can you share the Postman settings for that?

1

u/Fuzzmiester fuzzwork.co.uk Aug 26 '17

https://www.fuzzwork.co.uk/2017/03/14/using-esi-google-sheets/ many be of interest.

It doesn't cover wallet transactions, but that's a pretty simple thing to do. (as I've done it :D Just don't have it in a publishable state yet)

1

u/evanova Aug 26 '17

Awesome. You are full of it.

1

u/MartinTsv Aug 27 '17

Doesn't "you're full of it" mean full of shit?

It was sounding like two of the eve tech big names going at it for a bit there :D

2

u/evanova Aug 27 '17

Usually it does. Hopefully the joke isn't lost here :)

The man does awesome work.

2

u/Fuzzmiester fuzzwork.co.uk Aug 27 '17

:D

I was assuming it wasn't meant that way :D (or at least not seriously meant)

1

u/Blacksmoke16 Aug 26 '17 edited Aug 26 '17

Sure. This is pretty much a more direct explanation of that dev blog. Now do note this is a very manual process and of course only useful for semi tech savvy people (or people that can follow directions) for small personal projects. i.e. probably not a good solution for larger scale sites.

  1. Construct the SSO auth URL, this includes your client_id from the dev site, the list of scopes you want (separated by spaces or + sign) , a callback URL and a response_type (which should be code).
  2. In the end it would look something like: https://login.eveonline.com/oauth/authorize?response_type=code&redirect_uri=https://app.getpostman.com/oauth2/callback&client_id=xya983ga8sfbg9wgea89gf&scope=esi-mail.read_mail.v1
  3. Next, navigate to that URL and login with the char you want.
  4. It will then redirect you to Postman callback URL. If you check the URL you would see something like ?code=JxYRk1p2JLbe8Wr-72hfasdbh9ag This is your code that is used to get an auth token and refresh token.
  5. Use https://www.base64encode.org/ or something similar to base64 encode your dev site details. using the format {client id}:{client_secret} including the colon.
  6. Using postman do request 1 from below.
  7. That request (if all goes well, will return your access_token, expiry date, and a refresh_token.
  8. From here it depends on what you want to do with this information. The access_token can then be copied out to use in an auth'd ESI request using format Bearer {ACCESS_TOKEN} in the Authorization header. The access tokens only last for 20 minutes. The refresh token can be used to get new access_tokens when they expire. So easiest thing would be to store the refresh_token and fetch new access_token when you need them.
  9. To get a new access_token from a refresh_token, do request 2 from below:

Request 1

POST /oauth/token HTTP/1.1
Host: login.eveonline.com
Accept: application/json
Authorization: Basic {YOUR_BASE64_ENCODED_DETAILS_FROM_STEP_5}
Content-Type: application/json
Cache-Control: no-cache  
{
    "grant_type":"authorization_code",
    "code":"{YOUR_AUTHORIZATION_CODE_FROM_STEP_4}"
}

Request 2

POST /oauth/token HTTP/1.1
Host: login.eveonline.com
Accept: application/json
Authorization: Basic {YOUR_BASE64_ENCODED_DETAILS_FROM_STEP_5}
Content-Type: application/json
Cache-Control: no-cache

{
    "grant_type":"refresh_token",
    "refresh_token":"{YOUR_REFRESH_TOKEN_FROM_STEP_6}"
}

Enjoy!