|
1 |
| - |
2 | 1 |
|
3 |
| - |
4 | 2 |
|
5 | 3 |
|
| 4 | + |
| 5 | + |
| 6 | +# 🔒 Magic OAuth Extension for React Native (Bare) |
| 7 | + |
| 8 | +[](https://circleci.com/gh/magiclabs/magic-js) |
| 9 | + |
| 10 | +> With the Magic JavaScript SDK OAuth extension, you can plug into your favorite social login providers with one, easy-to-use API. |
| 11 | +
|
| 12 | +<p align="center"> |
| 13 | + <a href="https://github.com/magiclabs/magic-js/blob/master/packages/@magic-ext/oauth/LICENSE">License</a> · |
| 14 | + <a href="https://github.com/magiclabs/magic-js/blob/master/packages/@magic-ext/oauth/CHANGELOG.md">Changelog</a> · |
| 15 | + <a href="https://github.com/magiclabs/magic-js/blob/master/CONTRIBUTING.md">Contributing Guide</a> |
| 16 | +</p> |
| 17 | + |
| 18 | +## 📖 Documentation |
| 19 | + |
| 20 | +See the [developer documentation](https://magic.link/docs/social-login) to learn how to get started with OAuth in Magic SDK. |
| 21 | + |
| 22 | +## 🔗 Installation |
| 23 | + |
| 24 | +Integrating your app with OAuth will require our client-side NPM package and OAuth extension: |
| 25 | + |
| 26 | +```bash |
| 27 | +# Via NPM: |
| 28 | +npm install --save @magic-ext/react-native-bare-oauth |
| 29 | + |
| 30 | +# Via Yarn: |
| 31 | +yarn add @magic-ext/react-native-bare-oauth |
| 32 | +``` |
| 33 | +### ⚠️ This library can only be used on a bare react native project that uses [@magic-sdk/react-native-bare](https://github.com/magiclabs/magic-js/tree/master/packages/%40magic-sdk/react-native-bare). |
| 34 | + |
| 35 | +## ⚡️ Quick Start |
| 36 | + |
| 37 | +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. |
| 38 | + |
| 39 | +Then, you can start authenticating users with _just one method!_ |
| 40 | + |
| 41 | +```tsx |
| 42 | +import React from 'react'; |
| 43 | +import { Magic } from '@magic-sdk/react-native-bare'; |
| 44 | +import { OAuthExtension } from "@magic-ext/react-native-bare-oauth"; |
| 45 | +import { SafeAreaProvider } from 'react-native-safe-area-context'; |
| 46 | + |
| 47 | +const magic = new Magic(apiKey, { |
| 48 | + endpoint: 'https://box.magic.link', |
| 49 | + extensions: [ |
| 50 | + new OAuthExtension() |
| 51 | + ], |
| 52 | +}); |
| 53 | + |
| 54 | +export default function App() { |
| 55 | + return <> |
| 56 | + <SafeAreaProvider> |
| 57 | + {/* Render the Magic iframe! */} |
| 58 | + <magic.Relayer /> |
| 59 | + {...} |
| 60 | + </SafeAreaProvider> |
| 61 | + </> |
| 62 | +} |
| 63 | + |
| 64 | +// Somewhere else in your code... |
| 65 | +await magic. auth. loginWithEmailOTP({ email: '[email protected]' }); |
| 66 | +``` |
| 67 | +👉 Check out some of our [React Native Demo apps](https://github.com/magiclabs/react-native-demo) for inspiration! 👀 |
0 commit comments