Skip to content

breadbutter/breadbutter-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The official Java Client library for Bread & Butter

This library allows you to connect your application to the authentication process of Bread & Butter. A user will be redirected to your application when a user is authenticated. Once this authentication is retrieved by your application you can perform an action like creating a user in your system or creating a session for that users.

Download

Maven

<dependency>
    <groupId>io.breadbutter</groupId>
    <artifactId>breadbutter-java</artifactId>
    <version>5.2.0</version>
</dependency>

API

For more information on the full DIY Quick Start Guide visit https://app.breadbutter.io/api/

Once the user's authentication is processed on by Bread & Butter, the user is redirected to a callback interface defined in your Bread & Butter app. The example below is a simple interface that accepts the request from Bread & Butter and processes the authentication.

After the the interface is created you will need to update the Callback URL with the URL to this interface in your app settings here: https://app.breadbutter.io/app/#/app-settings

Processing an authentication request

Instantiating a new client

Create a new instance of BreadButterClient.

import io.breadbutter.BreadButterClient;

BreadButterClient client = new BreadButterClient("{APP_ID}", "{APP_SECRET}", "{BREADBUTTER_API_ENDPOINT}");

Retrieve authentication from Bread & Butter server

You can find the detailed API response here: https://breadbutter.io/api/server-api/

import io.breadbutter.BreadButterClient;
import io.breadbutter.dtos.GetAuthenticationResponse;
import io.breadbutter.dtos.AuthenticationData;
import io.breadbutter.dtos.AuthOptions;
import io.breadbutter.BreadButterException;


String authToken = request.getParameter("authentication_token"); 


GetAuthenticationResponse bbResponse = client.getAuthentication(authToken);

AuthenticationData authData = bbResponse.getAuthData();
String emailAddress = authData.getEmailAddress();
String firstName = authData.getFirstName();
String lastName = authData.getLastName();
String profileImage = authData.getProfileImageUrl();

AuthOptions authOptions = bbResponse.getOptions();
String destinationUrl = authOptions.getDestinationUrl();

Redirect the user back to your website

response.sendRedirect(destinationUrl);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages