ISIL-ESTE / Student-Workflow-Organizer

The Workflow Organizer website helps students to organize their academic workload through features such as a dashboard, timeline, reminders, collaboration tools, resource library, progress tracking, and analytics. It also allows users to share and summarize courses and seek project help.
MIT License
46 stars 20 forks source link

GitHub integration #58

Open bellaabdelouahab opened 1 year ago

bellaabdelouahab commented 1 year ago

This issue aims to implement the initial steps for GitHub integration and retrieve repositories this will unlock many possibilities in our application. here are tasks to be done :

bellaabdelouahab commented 1 year ago

@muttaqin1 do you want to take this ?

muttaqin1 commented 1 year ago

I havent done github integration before. This will be a big challenge for me.But i will try. @bellaabdelouahab

bellaabdelouahab commented 1 year ago

sure, but it's not that hard the hard part is managing access to certain things like email username repositories and other info. @muttaqin1

muttaqin1 commented 1 year ago

I have to use passport.js right? Then when a user log's in i will get a access token and refresh token i will store that in db so that i can do some api request's to Github api?

muttaqin1 commented 1 year ago

@bellaabdelouahab

bellaabdelouahab commented 1 year ago

here are some resources https://codevoweb.com/github-oauth-authentication-react-and-node/ @muttaqin1

muttaqin1 commented 1 year ago

yeah, I have read the blog. It was beneficial thank you. @bellaabdelouahab

muttaqin1 commented 1 year ago

Hello @bellaabdelouahab, Github Oauth doesn't give us access to user password. In that case i am willing to create a model to store github user info and access token. But if we allow null value on the password property in our USER model we can store the data which we will get from github.Then we have to create another model to store access token. So i believe the first option will be great for our use case.What do you think?

bellaabdelouahab commented 1 year ago

Hey @muttaqin1, Yes of course what we need to do is either two ways allow access without password or after connecting to github require the user to enter his password both options are good.

bellaabdelouahab commented 1 year ago

You don't need to create a new model just add the field of github access token to existing userModel

bellaabdelouahab commented 1 year ago

Another thing, Don't store data like repositories or projects... Just the needed data to create a user, About the repos and other info we will make it stateless.

muttaqin1 commented 1 year ago

Another thing, Don't store data like repositories or projects... Just the needed data to create a user, About the repos and other info we will make it stateless.

Yeah i know that.

bellaabdelouahab commented 1 year ago

@muttaqin1 any heads-up ?

muttaqin1 commented 1 year ago

90% done and now i'm fixing some bugs.I will submit a pr soon. @bellaabdelouahab

muttaqin1 commented 1 year ago

I have generated the jwt and set it to the browser using a secured cookie. then redirected to the path which i have got from the req.params.

const {code, path} = req.params

//...some tasks
//... generate jwt
//...set cookie

res.redirect(path);

Is there any other way where we don't have to use the cookie?

like this:

const {code} = req.params

//...some tasks
//... generate jwt

res.status(200).json({
user:createdUser,
token
})

But whenever the callback url is called by github. The server response open's in the browser. Because its a GET request.

@bellaabdelouahab

bellaabdelouahab commented 1 year ago

Can you give me some context like the workflow of github auth so i can understand

muttaqin1 commented 1 year ago

Screenshot_2023-07-12-18-38-52-47.jpg

@bellaabdelouahab