Skip to main content

LinkedIn Authentication Flow with Cloudflare and AWS

Overview

This document outlines the flow of authenticating a user with LinkedIn through Cloudflare and then passing the authentication token to AWS Cognito or a Lambda function.

Authentication Process

  1. User Initiates Login: The user clicks on the "Login with LinkedIn" button on the website.
  2. Redirect to LinkedIn via Cloudflare: The request is redirected through Cloudflare to LinkedIn's OAuth 2.0 endpoint.
  3. User Authenticates with LinkedIn: The user logs in with their LinkedIn credentials and grants necessary permissions.
  4. LinkedIn Returns Authorization Code: LinkedIn redirects back to Cloudflare with an authorization code.
  5. Cloudflare Exchanges Code for Token: Cloudflare exchanges the code for an access token from LinkedIn.
  6. Cloudflare Passes Token to AWS:
    • If using Cognito: Cloudflare redirects the user to the application with the token.
    • If using Lambda: Cloudflare invokes a Lambda function with the LinkedIn token.
  7. Cognito/Lambda Processes the Token: AWS processes the token, creating or validating a user session.
  8. Application Receives User Session: The application receives the session information, granting the user access to authenticated content.
  9. Retrieve User Data (Optional): Additional user data can be fetched from LinkedIn's API using the token.

Diagram

Refer to the accompanying Mermaid diagram for a visual representation of this flow.