GithubHelp home page GithubHelp logo

freedomfaighter / java-signature-generator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from blizzard/java-signature-generator

1.0 0.0 0.0 832 KB

A sample OAuth2 Client Credentials flow application using Blizzard Battle.net APIs in Java.

Home Page: https://develop.battle.net

License: MIT License

java-signature-generator's Introduction

Signature Generator (Java Sample Project)

Provided as a sample implementation of the OAuth2 Client Credentials flow, using the Blizzard Battle.net APIs for data.

Creates a web service that generates an image based on a World of Warcraft character profile on demand.

Setup

Requirements

Environment variables

As we don't wish to commit our secrets into this repository, this project requires a few environment variables set in order to successfully execute, much like you would expect to see in various hosting services. We do not recommend committing your secrets in your project's code repository either.

Variable Name Variable Usage
BLIZZARD_CLIENT_ID The Client ID from https://develop.battle.net/access for your project
BLIZZARD_CLIENT_SECRET The Client Secret from https://develop.battle.net/access for your project

For local development, you can set the environment variables yourself.

For Windows users, run the following commands from a command prompt:

set BLIZZARD_CLIENT_ID=<YOUR_CLIENT_ID_GOES_HERE>
set BLIZZARD_CLIENT_SECRET=<YOUR_CLIENT_SECRET_GOES_HERE>

For POSIX users, run the following commands in a terminal:

export BLIZZARD_CLIENT_ID=<YOUR_CLIENT_ID_GOES_HERE>
export BLIZZARD_CLIENT_SECRET=<YOUR_CLIENT_SECRET_GOES_HERE>

Result

If successful, you will see a Spring Boot application console log which will allow you to submit a GET request at the following endpoint: http://localhost:8080/signature?characterName=CHARACTERNAME&realmName=REALMNAME

Note: make sure to use the programmatic realm name, ex: "Area 52" would be "area-52" in the URL

The result will be a signature generated describing the character.

Notes

This code makes heavy use of the Lombok library for both the @Data annotation and @Log4j2 annotations to save a lot of boilerplate code for POJOs and Logging.

Similarly, we use Spring's RestTemplate.exchange to execute our GET requests, and transform the results into Java objects, described by the above Lombok annotated classes. This was chosen, to allow the flexibility in submitting the token via header or via url parameter with minimal forking logic.

We recommend submitting your token in the header on general security principals, as the URL requested is frequently scraped and logged, which effectively steals an application's identity to make requests into our API system.

This is only intended as a launching point for developers to see an example application. There are many areas that could be improved.

There are many solutions for managing secrets and that topic is beyond the scope of this example to delve into. Please perform your own due-diligence when researching this topic and implementing it.

java-signature-generator's People

Contributors

tsitra avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.