Socket
Socket
Sign inDemoInstall

@magic-ext/oauth

Package Overview
Dependencies
1
Maintainers
25
Versions
459
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @magic-ext/oauth

Magic SDK OAuth Extension for Web environments.


Version published
Maintainers
25
Install size
547 kB
Created

Readme

Source

🔒 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;

FAQs

Last updated on 01 Apr 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc