Brewery-API uses BreweryDB to obtain information about breweries. It allows to:
- Get a Single Brewery by id
- List Breweries
- Search Breweries
You can check the Swagger for more information about each endpoint.
Brewery-API uses the OAuth 2.0 protocol (client credentials grant) for authentication and authorization. It's using okta as the authorization server.
The application is deployed using AWS Elastic Beanstalk under the domain https://brewery.gfonseca.io.
- Units tests
- Functional tests with Wiremock
- Java 11
- Maven
- Docker
Build Jar
mvn clean intall
Build Docker Image
docker build . -t brewery-api
Run Application
docker run -p 8080:80 \
-e CLIENT_ID=<CLIENT_ID> \
-e CLIENT_SECRET=<CLIENT_SECRET> \
brewery-api
To get an access token you need to make a request to the authorization server:
POST /oauth2/default/v1/token HTTP/1.1
Host: dev-8089486.okta.com
Accept: application/json
Content-Type: application/x-www-form-urlencoded
Authorization: Basic base64(<CLIENT_ID>:<CLIENT_SECRET>)
grant_type=client_credentials&scope=read
The authorization server will respond with the following payload:
{
"token_type": "Bearer",
"expires_in": 600,
"access_token": <TOKEN>,
"scope": "read"
}
Then you need to add an Authorization
header with token to all requests to the Brewery-API
GET /breweries/530 HTTP/1.1
Host: brewery.gfonseca.io
Authorization: Bearer <TOKEN>
To more easily test the api you can import the postman collection into postman and define the variables {{client_id}} and {{client_secret}}. This collection, after the Get Token
request automatically adds the token to the other requests.