This project is an example on how to setup a Java/Spring project to consume BattleNet API OAuth2.
This was made using spring tutorial Spring Boot and OAuth2 and doc from Battle.net
[TOC]
First off, You want to sign up with Mashery on the Battle.net Developer Portal.
Then you want to register your futur app.
Note:
- The website, the name of the app can always be changed afterwards
You must follow these easy steps following This tutorial (Only the first 2 steps are usefull here)
Summary of the tutorial:
- Generate a self-signed certificate
keytool -genkey -alias tomcat -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650
- Enable HTTPS in Spring boot but putting those lines in the
application.properties
server.port: 8443 server.ssl.key-store: keystore.p12 server.ssl.key-store-password: mypassword server.ssl.keyStoreType: PKCS12 server.ssl.keyAlias: tomcat
Enter your own public and secret key in the application.properties file. Enter as well all the URLs (acces Token, Authorization, ...) Here for more details
You can login to your app by clicking the link
You're redirected to battle.net portal to make sure you authorize your new web-app to access informations like BattleTag, World of Warcraft Characters and/or Starcraft profile.
You can access infos like your battletag or your id with "https://eu.api.battle.net/account/user?access_token=..." You can access more info on World of Warcraft account or Starcraft account with another API call (All listed on battle net developer portal)
Front information access :
You can also get those information on your back end (if you want to save users and their alts for example)
note: This is for example purpose only, do not mind the unchecked casting :)