-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
auth with GitHub using nuxt auth module #48
Comments
I would like to pick this one @lukeocodes Could you provide more info on this? |
@git-srinivas I would like to be able to log in to GitHub from the Nuxt application, hopefully without the need for a backend. If you need a backend, please create a Netlify function to act as the backend. |
okay and also i need to create a form for user credentials? |
No, you should use GitHub OAuth2 workflow |
okay. |
I could see that we are already authenticated with github personal access token and able to get repositories information. You mean to provide login functionality to the website visiting user? |
Hi and yes. I should have updated the issue when you first showed interest, sorry for the lack of info. There are a few ways to connect to GitHub APIs. One is using a static personal access token (mine), which is stored as an environment variable and deployed to the Netlify Function (AWS Lambda function) that connects to GitHub. Another way is to have a user of the site "Login with GitHub", they then get an Acess Token which can be stored in the memory of the frontend application (not in cookies or local storage), then sent through to the Netlify Function whenever they make a request. Not only for this purpose, but it also will provide the users GitHub profile information, to enrich the experience on the site (i.e. they could track their entire Hacktoberfest progress). There are packages like |
No worries. I will go through the documentation and thanks for the info 👍 |
Editing with info for anyone who wants to help with this one.
There are a few ways to connect to GitHub APIs.
One is using a static personal access token (mine), which is stored as an environment variable and deployed to the Netlify Function (AWS Lambda function) that connects to GitHub.
Another way is to have a user of the site "Login with GitHub", they then get an Acess Token which can be stored in the memory of the frontend application (not in cookies or local storage), then sent through to the Netlify Function whenever they make a request. Not only for this purpose, but it also will provide the users GitHub profile information, to enrich the experience on the site (i.e. they could track their entire Hacktoberfest progress).
There are packages like
nuxt-auth
that will make some of this work easier, but from my own experimentation, those packages offered incomplete solutions. I believe I was closest withnuxt-auth
, which appeared to be using an auth code grant, but I should have created a new Netlify Function to act as the backend to exchange the authorization code for an access token.GitHub has some guides on building an OAuth application.
The text was updated successfully, but these errors were encountered: