# @magic-ext/oauth2

> Magic SDK OAuth Extension for Web environments.

Latest version **15.14.0** (published 2026-09-01) · MIT license · 9.9K weekly downloads

## Install

```sh
npm install @magic-ext/oauth2
pnpm add @magic-ext/oauth2
yarn add @magic-ext/oauth2
bun add @magic-ext/oauth2
```

## Health

**Score 80/100 (A)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

## Facts

| | |
|---|---|
| Version | 15.14.0 |
| Published | 2026-09-01 |
| First published | 2024-02-13 |
| Weekly downloads | 9.9K |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 446.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (Unknown) |
| GitHub stars | 476 |
| Author | Magic |
| Maintainers | ethella, jasonatmagic, magiclabs_fe, noahyoshida, ernieyang09, josh_scanlan |

## Links

- npm: https://www.npmjs.com/package/@magic-ext/oauth2
- Repository: https://github.com/magiclabs/magic-js
- Homepage: https://github.com/magiclabs/magic-js#readme
- Issues: https://github.com/magiclabs/magic-js/issues
- npm.io page: https://npm.io/package/@magic-ext/oauth2

## Dependencies (1)

- [crypto-js](https://npm.io/package/crypto-js.md) ^4.2.0

## Recent versions

- 15.14.0 (latest) — 2026-09-01
- 15.14.0-canary.88f8a7c.0 (canary) — 2026-09-01
- 15.14.0-canary.1127.33539959419.0 — 2026-09-01
- 15.13.0 — 2026-08-26
- 15.13.0-canary.8ab4816.0 — 2026-08-26
- 15.13.0-canary.1125.32991648608.0 — 2026-08-26
- 15.12.0 — 2026-08-25
- 15.12.0-canary.5c46f47.0 — 2026-08-25
- 15.12.0-canary.1124.32876468895.0 — 2026-08-25
- 15.11.3-canary.1111.31717158054.0 — 2026-08-13
- 15.11.3-canary.1111.31664883805.0 — 2026-08-13
- 15.11.1-canary.1109.31539218924.0 — 2026-08-12
- 15.11.2 — 2026-08-12
- 15.11.2-canary.cc406ba.0 — 2026-08-12
- 15.11.2-canary.1110.31607645687.0 — 2026-08-12
- … 839 more at https://npm.io/package/@magic-ext/oauth2/versions

## README

# 🔒 Magic OAuth Extension for Web Browsers

[![<MagicLabs>](https://circleci.com/gh/magiclabs/magic-js.svg?style=shield)](https://circleci.com/gh/magiclabs/magic-js)

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

<p align="center">
  <a href="https://github.com/magiclabs/magic-js/blob/master/packages/@magic-ext/oauth2/LICENSE">License</a> ·
  <a href="https://github.com/magiclabs/magic-js/blob/master/packages/@magic-ext/oauth2/CHANGELOG.md">Changelog</a> ·
  <a href="https://github.com/magiclabs/magic-js/blob/master/CONTRIBUTING.md">Contributing Guide</a>
</p>

## 📖 Documentation

See the [developer documentation](https://magic.link/docs/social-login) 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:

```bash
# 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>`:

```html
<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](https://dashboard.magic.link) 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:

```ts
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:

```ts
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;
```

---
_Source: https://npm.io/package/@magic-ext/oauth2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
