A Java client library for the new EVE Swagger Interface (ESI)
Just add the following to your pom.xml:
<dependency>
<groupId>net.troja.eve</groupId>
<artifactId>eve-esi</artifactId>
<version>1.0.0</version>
</dependency>
The usage of the SSO can be seen in the main method within the test class net/troja/eve/esi/api/auth/SsoAuthTest.java.
Note: The state should be some secret to prevent XRSF, please read: http://www.thread-safe.com/2014/05/the-correct-use-of-state-parameter-in.html
To run the tests that use authorization you need to have some environment variables set, this information should not be published:
- SSO_CLIENT_ID
- SSO_CLIENT_SECRET
- SSO_REFRESH_TOKEN
Client id and secret can be created on the following page: https://developers.eveonline.com/ You should use http://localhost as redirect url as that is the value used in the test and it also makes it easier after the redirect.
To create a refresh token, you have to start the class net/troja/eve/esi/api/auth/SsoAuthTest.java with your client id as first and the secret as second argument. Then it shows you the url on console.
Open the url in your browser, login with your account and authorize the access. This will redirect you to an url on localhost, something like:
http://localhost/?code=7z524J_PQZ1YjacS35d8JRkOVwNl-jCvn814xCrgeSm3Acc981lZWW0&state=somesecret
Copy the code part to console and press enter. As result you will get a refresh token, that can be used to run the tests.
Example output:
Authorization URL: https://login.eveonline.com/oauth/authorize?scope=esi-clones.read_clones.v1&response_type=code&state=somesecret&redirect_uri=http%3A%2F%2Flocalhost&client_id=352ef22ca74e33c78c11779ab3saffe
Code from Answer: 7z524J_PQZ1YjacS35d8JRkOVwNl-jCvn814xCrgeSm3Acc981lZWW0
Refresh Token: 0tr5SQ-piuKvqjFdDa765DESObTzWKUj5v63KjaL4cTAx041
If you wonder how the paging with esi works, please have a look at the test src/test/java/net/troja/eve/esi/api/MarketApiTest.java there is a method pagingExample showing it.
When you get that exception with eve-esi, you have to add the following dependency to your pom.xml
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${jersey.version}</version>
</dependency>
- Download Cygwin from: https://www.cygwin.com
- Install Cygwin with the default options
- Run the Cygwin installer again and add: wget (web), git (devel), jq (text)
- Download maven from: http://maven.apache.org/download.cgi (if you don't have it installed already)
- Unpack and add the "bin" directory to windows environment variable "path"
- Download and install Java SE JDK: http://www.oracle.com/technetwork/java/javase/downloads/index.html (if you don't have it installed already)
- Start the Cygwin Terminal
cd
to the source- run
./generate.sh