Integration Guide

Overview

This document outlines the steps required to integrate OAuth2 authentication for Lemonade services in your application. It includes acquiring necessary credentials, setting up endpoints, and handling authorization and token refresh flows.

Prerequisites

Obtain client_id and client_secret from Lemonade. Note that this process is currently managed internally and does not have a UI interface.

OAuth2 Endpoints

Lemonade OAuth2 utilizes the following endpoints:

  1. Authorization: https://oauth2.lemonade.social/oauth2/auth

  2. Token: https://oauth2.lemonade.social/oauth2/token

  3. User Information: https://oauth2.lemonade.social/userinfo

  4. End Session: https://oauth2.lemonade.social/oauth2/sessions/logout

Library Usage

We use oidc-client-ts for handling the authorization flow and managing session/tokens.

Configuration

First, import and configure the UserManager from oidc-client-ts:

Authorization Flow

  1. Initiate Login:

Perform a call to the authorization endpoint:

This will redirect to Lemonade Identity for user login and consent (currently auto-skipped). After login, it redirects to /oauth2/callback.

  1. Handle Callback:

Process the callback to obtain the user response:

response includes access tokens and refresh tokens, which should be stored within your application.

  1. Making Requests:

Token Refresh Flow

Access tokens are valid for 1 hour. To refresh:

Log Out Flow

To perform a logout:

Last updated