Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@globus/react-auth-context

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@globus/react-auth-context

A React context for integrating Globus Auth into your application using the Globus JavaScript SDK

  • 0.0.2
  • npm
  • Socket score

Version published
Weekly downloads
69
decreased by-31%
Maintainers
0
Weekly downloads
 
Created
Source

npm

@globus/react-auth-context

A simple React context for managing Globus-related authentication state.

Usage

import React, { useEffect } from "react";
import { Provider, useGlobusAuth } from '@globus/react-auth-context';

const ExampleComponent = () => {
  const { isAuthenticated, authorization } = useGlobusAuth();
    useEffect(() => {
    async function attempt() {
      if (!isAuthenticated) {
        await instance?.handleCodeRedirect({
          shouldReplace: false,
        });
      }
    }
    attempt();
  }, [authorization, authorization?.handleCodeRedirect, isAuthenticated]);

  return (
    <div>
      {isAuthenticated ? (
        <button onClick={async () => await auth.authorization?.revoke()}>Logout</button>
      ) : (
        <button  onClick={() => auth.authorization?.login()}>Login</button>
      )}
    </div>
  );
};

/**
 * Your registered Globus Client ID.
 */
const client = '645b6bfb-4195-4010-83f5-a71332bd4761';
/**
 * Scopes required for your application on login.
 */
const scopes = 'urn:globus:auth:scope:transfer.api.globus.org:all';
/**
 * Redirect URL that will complete the OAuth2 flow.
 */
const redirect = '/';

const App = () => (
  <Provider client={client} scopes={scopes} redirect={redirect}>
    <ExampleComponent />
  </Provider>
);

FAQs

Package last updated on 04 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc