Skip to content

Instantly share code, notes, and snippets.

@putrikarunia
Created September 8, 2020 07:56
Show Gist options
  • Save putrikarunia/7788960523cc0c46e67a5133c4ed1ac8 to your computer and use it in GitHub Desktop.
Save putrikarunia/7788960523cc0c46e67a5133c4ed1ac8 to your computer and use it in GitHub Desktop.
import Cotter from "cotter";
export default function Dashboard() {
...
// Get a list of repositories
useEffect(() => {...}, []);
const getRepositories = async () => {...};
const connectToGithub = async () => {
var cotter = new Cotter(API_KEY_ID); // 👈 Specify your API KEY ID here
const accessToken = await cotter.tokenHandler.getAccessToken();
cotter.connectSocialLogin("GITHUB", accessToken?.token); // pass in the provider's name
};
return (
<>
<Navbar />
<div className={styles.container}>
{/* Show any error here */}
...
{/* If there's no Github access token, show a button to connect a Github account */}
{err?.includes("Fail getting Github access token from Cotter API") && (
<div className={styles.card} onClick={connectToGithub}>
Connect Github
</div>
)}
{/* Show the list of repositories */}
...
</div>
</>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment