Created
October 24, 2019 04:22
-
-
Save PrimeTimeTran/566b8751a950fd1aeb786e15feac0fa3 to your computer and use it in GitHub Desktop.
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
useEffect(() => { | |
const existingToken = sessionStorage.getItem("token"); | |
const accessToken = | |
window.location.search.split("=")[0] === "?access_token" | |
? window.location.search.split("=")[1] | |
: null; | |
if (!accessToken && !existingToken) { | |
window.location.replace( | |
`https://github.com/login/oauth/authorize?scope=user:email,repo&client_id=${clientId}` | |
); | |
} | |
if (accessToken) { | |
setToken(accessToken); | |
sessionStorage.setItem("token", accessToken); | |
} | |
if (existingToken) { | |
setToken(existingToken); | |
} | |
getIssues(); | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment