This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
async function getGitHubUserData(access_token) { | |
const { data } = await axios({ | |
url: 'https://api.github.com/user', | |
method: 'get', | |
headers: { | |
Authorization: `token ${access_token}`, | |
}, | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
import * as queryString from 'query-string'; | |
async function getAccessTokenFromCode(code) { | |
const { data } = await axios({ | |
url: 'https://github.com/login/oauth/access_token', | |
method: 'get', | |
params: { | |
client_id: process.env.APP_ID_GOES_HERE, | |
client_secret: process.env.APP_SECRET_GOES_HERE, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as queryString from 'query-string'; | |
const urlParams = queryString.parse(window.location.search); | |
console.log(`The code is: ${urlParams.code}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as queryString from 'query-string'; | |
const params = queryString.stringify({ | |
client_id: process.env.APP_ID_GOES_HERE, | |
redirect_uri: 'https://www.example.com/authenticate/github', | |
scope: ['read:user', 'user:email'].join(' '), // space seperated string | |
allow_signup: true, | |
}); | |
const githubLoginUrl = `https://github.com/login/oauth/authorize?${params}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
async function getFacebookUserData(access_token) { | |
const { data } = await axios({ | |
url: 'https://graph.facebook.com/me', | |
method: 'get', | |
params: { | |
fields: ['id', 'email', 'first_name', 'last_name'].join(','), | |
access_token: accesstoken, | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
async function getAccessTokenFromCode(code) { | |
const { data } = await axios({ | |
url: 'https://graph.facebook.com/v4.0/oauth/access_token', | |
method: 'get', | |
params: { | |
client_id: process.env.APP_ID_GOES_HERE, | |
client_secret: process.env.APP_SECRET_GOES_HERE, | |
redirect_uri: 'https://www.example.com/authenticate/facebook/', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as queryString from 'query-string'; | |
const urlParams = queryString.parse(window.location.search); | |
console.log(`The code is: ${urlParams.code}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as queryString from 'query-string'; | |
const stringifiedParams = queryString.stringify({ | |
client_id: process.env.APP_ID_GOES_HERE, | |
redirect_uri: 'https://www.example.com/authenticate/facebook/', | |
scope: ['email', 'user_friends'].join(','), // comma seperated string | |
response_type: 'code', | |
auth_type: 'rerequest', | |
display: 'popup', | |
}); |