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

23.2.0 โ€ข Public โ€ข Published

๐Ÿ”’ Magic OAuth Extension for Web Browsers

We suggest use OAUTH2 @magic-ext/oauth2 package for the best performance

<MagicLabs>

With the Magic JavaScript SDK OAuth 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 extension:

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

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

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/oauth/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/oauth';

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

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

From your OAuth callback page:

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

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

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

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

/@magic-ext/oauth/

    Package Sidebar

    Install

    npm i @magic-ext/oauth

    Weekly Downloads

    8,126

    Version

    23.2.0

    License

    MIT

    Unpacked Size

    146 kB

    Total Files

    15

    Last publish

    Collaborators

    • seanli
    • damianjachyra
    • ethella
    • hcote
    • mikeysight
    • jasonatmagic
    • magiclabs_fe
    • jonathansoper
    • darrentmagic
    • khaledali.magic
    • ritalestermagic
    • dizigen
    • jmac-magic
    • noahyoshida
    • jfifer-b9s
    • alexandermann
    • zilanouyang