appsync-auth0 icon indicating copy to clipboard operation
appsync-auth0 copied to clipboard

Authenticating an AWS AppSync GraphQL API with Auth0

Authenticating AWS AppSync with Auth0

This repo goes along with the Medium blog post Authenticating an AWS AppSync GraphQL API with Auth0.

To use this repo, you must have the following credentials:

  1. An Auth0 API configured with RS256 signing algorithm for both general & OAuth signing.
  2. AWS AppSync API configured with your Auth0 app domain.

Getting started

  1. Clone the repo
git clone https://github.com/dabit3/appsync-auth0.git
  1. Change into the new directory
cd appsync-auth0
  1. Install dependencies
npm i
# or
yarn
  1. Update the AppSync graphqlEndpoint in AppSync.js with your AppSync endpoint.

  2. In App.js, configure the call to Auth0 with your credentials:

this.auth0 = new auth0.WebAuth({
  domain: '<YOURAPPDOMAIN>.auth0.com',
  clientID: '<YOURCLIENTID>',
  redirectUri: 'http://localhost:3000/callback',
  audience: 'https://<YOURAPPDOMAIN>.auth0.com/userinfo',
  responseType: 'token id_token',
  scope: 'openid'
});
  1. Run the app
npm start