GitHub Social Login with Magic
GitHub Social Login with Magic
#Overview
You can allow your users to sign up & log in to your web app with their GitHub account.
#Usage
#Prerequisites
- You will need a GitHub account
- You will need to have the Magic SDK installed into your web app
- You will need to have the Magic SDK - OAuth Extension installed into your web app
#GitHub Setup (v1 extension)
After installing the OAuth extension, you can now enable GitHub Login for your Magic app:
- Follow GitHub's instructions to create an OAuth app
- Go to your Magic Dashboard
- Select the Magic app for which you’d like to enable Github Login, or create a new app
- Navigate to Social Login from the sidebar
- Click the toggle for GitHub
- Copy the Redirect URI field from your Magic Dashboard
- Return to your GitHub Dashboard and paste the Redirect URI you obtained from your Magic Dashboard into the "Authorization callback URL" field
- Click "Register App" to complete your GitHub OAuth app setup.
- On the next page, obtain the "Client ID" and "Client Secret"
- Return to your Magic Dashboard and input the Client ID and Client Secret for your GitHub OAuth app
- In Magic Dashboard, click “Save” – Done!
#GitHub Setup (v2 extension)
- Follow above steps, but disregard Magic's Redirect URI in step 6
- In step 7, paste the Redirect URI you are passing in as the redirectURI argument to the loginWithRedirect method
Javascript
01await magic.oauth2.loginWithRedirect({
02 provider: 'github',
03 redirectURI: 'https://your-app.com/your/oauth/callback', // <== whitelist this with GitHub
04});