@magic-ext/oauth2
TypeScript icon, indicating that this package has built-in type declarations

9.0.6 • Public • Published

🔒 Magic OAuth Extension for Web Browsers

<MagicLabs>

With the Magic JavaScript SDK OAuth 2 extension, you can plug into your favorite social login providers with one, easy-to-use API.

License · Changelog · Contributing Guide

📖 Documentation

See the developer documentation to learn how to get started with OAuth in Magic SDK.

🔗 Installation

Integrating your app with OAuth will require our client-side NPM package and OAuth 2 extension:

# Via NPM:
npm install --save magic-sdk @magic-ext/oauth2

# Via Yarn:
yarn add magic-sdk @magic-ext/oauth2

Alternatively, you can load via CDN with by adding a script tag to your app’s <head>:

<script src="https://cdn.jsdelivr.net/npm/magic-sdk/dist/magic.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@magic-ext/oauth2/dist/extension.js"></script>

⚡️ Quick Start

Sign up or log in to the developer dashboard to receive API keys that will allow your application to interact with Magic's authentication APIs.

Then, you can start authenticating users with just two method calls!

From your login page:

import { Magic } from 'magic-sdk';
import { OAuthExtension } from '@magic-ext/oauth2';

const magic = new Magic('YOUR_API_KEY', {
  extensions: [new OAuthExtension()]
});

await magic.oauth2.loginWithRedirect({
  provider: 'google' | 'facebook' | 'github' | ...
});

From your OAuth callback page:

import { Magic } from 'magic-sdk';
import { OAuthExtension } from '@magic-ext/oauth2';

const magic = new Magic('YOUR_API_KEY', {
  extensions: [new OAuthExtension()],
});

const res = await magic.oauth2.getRedirectResult();

// Then you can access a user's Magic DID token, OpenID Connect profile information, and more!
res.magic.idToken;
res.oauth.userInfo;

/@magic-ext/oauth2/

    Package Sidebar

    Install

    npm i @magic-ext/oauth2

    Weekly Downloads

    497

    Version

    9.0.6

    License

    MIT

    Unpacked Size

    56.6 kB

    Total Files

    14

    Last publish

    Collaborators

    • ritalestermagic
    • darrentmagic
    • romin-halltari
    • magictristan
    • musicbender
    • jay.hwang
    • benmagic
    • dizigen
    • sgdheeban
    • mikeysight
    • ethella
    • damianjachyra
    • magiclabs_fe
    • jasonatmagic
    • bcleary06
    • hcote
    • seanli