https://github.com/mzlnk/oauth2-exchange
OAuth2 Exchange is a Java library that provides a bunch of functionalities for exchanging authorization code for an access token in OAuth2 Authorization Code Flow.
https://github.com/mzlnk/oauth2-exchange
java-17 oauth2 oauth2-authorization oauth2-authorization-code-flow spring-boot spring-boot-starter
Last synced: 6 months ago
JSON representation
OAuth2 Exchange is a Java library that provides a bunch of functionalities for exchanging authorization code for an access token in OAuth2 Authorization Code Flow.
- Host: GitHub
- URL: https://github.com/mzlnk/oauth2-exchange
- Owner: mzlnk
- License: mit
- Created: 2021-12-29T10:01:06.000Z (over 4 years ago)
- Default Branch: develop
- Last Pushed: 2022-03-10T21:15:58.000Z (over 4 years ago)
- Last Synced: 2025-07-26T10:15:18.834Z (11 months ago)
- Topics: java-17, oauth2, oauth2-authorization, oauth2-authorization-code-flow, spring-boot, spring-boot-starter
- Language: Java
- Homepage: https://github.com/mzlnk/oauth2-exchange
- Size: 291 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OAuth2 Exchange Library for Java
[](https://shields.io/)
[](https://shields.io/)
[](https://jdk.java.net/17/)
[](https://github.com/ellerbrock/open-source-badges/)
## About
OAuth2 Exchange is a Java library that provides a bunch of functionalities for exchanging authorization code for an access token
in OAuth2 Authorization Code Flow. It consists of templates and ready-to-use implementations for most common authorization providers
(like Google or Facebook). The mentioned templates make a proper HTTP call to issue an access token based on provided authorization code.
Therefore, you can save your time as you do not need to search through plenty of API docs or to implement a custom HTTP client just to
exchange a code for a token - the library do it under the hood via a single method call ;)
According to the [OAuth2 overview](https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2) found on DigitalOcean,
the library manages the step 4 (issuing a token from authorization code) and step 5 (receiving token response):

Apart from the core library which can be used in any Java project, there is also a dedicated starter for Spring Boot provided. It wraps the core library
and automatically configures proper templates based on provided credentials via application properties. Therefore, you do not need to bother about declaring
necessary beans and other related stuff in your Spring Boot application ;)
You can find out more about implementation details and how to get started with a library on [GitHub wiki pages](https://github.com/mzlnk/oauth2-exchange/wiki/Welcome-to-the-OAuth2-Exchange-Wiki!) or official [Java docs](https://www.javadoc.io/doc/io.mzlnk.oauth2.exchange/oauth2-exchange-core).
## Development
The whole project is currently in development, so you can expect plenty of updates over time.
| type | current version |
| ------ | --------------- |
| stable | 0.1.1 |
| latest | 0.2.0-SNAPSHOT |
### Supported auth providers
Currently, the oauth2-exchange library provides *ready-to-use* support for the following auth providers:
- [Facebook](https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/)
- [GitHub](https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps)
- [Google](https://developers.google.com/identity/protocols/oauth2/web-server)
- [Keycloak](https://www.keycloak.org/docs/latest/server_admin/)
- [Microsoft](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow)
- [Okta](https://developer.okta.com/docs/reference/api/oidc/#_2-okta-as-the-identity-platform-for-your-app-or-api)
### Snapshots
Every successfull build from `develop` branch is automatically deployed in form of snapshot to a public Sonatype repository.
### See a bug?
Have noticed a bug in a library? Do not hesitate to report it by creating an GitHub issue!
### Want to contribute?
If you want to contribute to the source code:
- find an issue you want to work on (or create a new one if you want to create something new)
- fork the project
- implement the feature/fix (do not forget about test coverage!)
- create a pull request to `develop` branch
## How to install
### Standalone library
#### Using Maven
If you want to use the core library itself in your Maven project - just include the dependency in your `pom.xml` file:
```xml
io.mzlnk.oauth2.exchange
oauth2-exchange-core
0.1.1
```
#### Using Gradle
If you want to use the core library itself in your Gradle project - just include the dependency `build.gradle` file:
```text
implementation 'io.mzlnk.oauth2.exchange:oauth2-exchange-core:0.1.1'
```
#### Using standalone JAR file
If you want to manually add the core library in your Java project - you can always download the proper JAR file from [Releases](https://github.com/mzlnk/oauth2-exchange/releases) page.
### Starter for Spring Boot
#### Using Maven
If you want to use the Spring Boot starter in your Maven project - just include the dependency in your `pom.xml` file:
```xml
io.mzlnk.oauth2.exchange
oauth2-exchange-spring-boot-starter
0.1.1
```
#### Using Gradle
If you want to use the core library itself in your Gradle project - just include the dependency `build.gradle` file:
```text
implementation 'io.mzlnk.oauth2.exchange:oauth2-exchange-spring-boot-starter:0.1.1'
```
## Documentation
If you want to get to know how the whole library works and how to use it in your project - you can check out [GitHub wiki pages](https://github.com/mzlnk/oauth2-exchange/wiki/Welcome-to-the-OAuth2-Exchange-Wiki!)
which include guides and tutorials. There are also official [Java docs](https://www.javadoc.io/doc/io.mzlnk.oauth2.exchange/oauth2-exchange-core) for core library.
## Credits
This starter is under MIT licence so feel free to use it for your personal or commercial use ;)
Created by Marcin Zielonka