globus / globus-auth-example-javascript

Example React application that uses PKCE with Globus Auth.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Globus Examples

Globus Auth Example: A Javascript React SPA

This repo provides an example of integrating Globus Auth into a Javascript React Single Page Application (SPA). You can use this to integrate an auth layer into your application so that users can log in with any of the thousands of Globus-integrated identity providers.

The example uses js-pkce to do a PKCE flow for Globus Auth authentication and authorization. When the user is redirected back to the application from Globus Auth the token(s) are retrieved and you can use those to perform any actions you like.

Installation and Starting

  1. Install Node.JS and NPM
  2. Run npm install to install packages
  3. Update the Auth configuration to
  4. Run npm start to start the application

Configuration

The application is configured in Auth.js. Set your Globus Auth native client ID and other parameters here:

const PkceAuth = new PKCE({
  client_id: 'a63334f4-df31-4a43-9396-14c2615b3391',  // Update this using your native client ID
  redirect_uri: 'http://localhost:3000',  // Update this if you are deploying this anywhere else (Globus Auth will redirect back here once you have logged in)
  authorization_endpoint: 'https://auth.globus.org/v2/oauth2/authorize',  // No changes needed
  token_endpoint: 'https://auth.globus.org/v2/oauth2/token',  // No changes needed
  requested_scopes: 'openid profile email',  // Update with any scopes you would need, e.g. transfer
});

To configure it for your own application:

  1. Create a Globus Auth native client here
  2. Set up any restrictions, such as required identity providers, during this step
  3. Update the client ID, your redirects, and any additional scopes your need here

Questions and Support

Please feel to reach out with any support questions at Globus Support.

About

Example React application that uses PKCE with Globus Auth.


Languages

Language:TypeScript 71.1%Language:HTML 15.6%Language:CSS 7.3%Language:JavaScript 6.1%