- Get all the public repositories of any valid username on github.
- Get all the followers of a user sorted by name.
- Get the most popular follower of a user among all.
- Create repository(requires access token)
- Edit description of the respository (requires access token).
- You might face PYTHONPATH issue. Inside
/SampleProject
folder doexport PYTHONPATH=$PWD
- Create virtual env
pipenv shell
. - run
pipenv install
- will install all the necessary lib from pipfile - start django application -
python manage.py runserver
. If successful, Try this url on you browserhttp://localhost:8000/repos/Nair18/
, if you get a bunch of jsons on your screen then that's a green light. - run
npm install
for setting react app. If you see error, try removing thepackage-lock.json
file and try again. - run
npm start
for starting the app - No db involved.
- GET 'localhost:8000/repos/:username'
- GET 'localhost:8000/followers/:username'
- GET 'localhost:8000/popular_follower/:username'
- POST 'https://api.github.com/repos/:owner'
- PATCH 'https://api.github.com/repos/:owner/:repo'
1,2,3
are served from Django application running on port 8000 while 4,5
are handled directly from the react app running on port 3000. Check out SampleProject/GitFetch/views.py
for the 'GET' rest apis. For client, checkout the client/antd-demo/src
folder. This is were the magic happens!
The whole project is a simple crud app, mostly GET
calls. The most interesting part is the POST
and PATCH
that happen for create and edit repository for an authorized user.
- Create your own oauth application by visiting
/developer settings/Oauth apps
from your github settings page. - Mention the homepage url and the callback url(a path of your application github redirects, after user clicks authorize).
- Thats it, hit enter to create the oauth app. You will get your client id and client secret.
- Now add a
Sign in with github
button and add redirect url to your oauth app. When user clicks on the sign in button, he will be redirected to your oauth application. When the user clicks authorize, github will redirect to the callback url(whatever you mentioned) along with acode
. - Use this
code
in the url and do a post call tohttps://github.com/login/oauth/access_token
and get the access token, here I store it in the localstorage since no db. With the access token in hand, you are stronger than THANOS now. - Once the token is received, everything else is pretty much trivial. You can play around with user's "limited" data.
- This whole process is handled in the react app.
- Unit tests for backend are very few. Since I didnt have enough bandwidth.
- Unit tests for frontend.
- github oauth process - https://docs.github.com/en/developers/apps/authorizing-oauth-apps
- api docs for playing around with repos - https://developer.github.com/v3/repos/#create-a-repository-for-the-authenticated-user
- api docs for user related stuffs - https://docs.github.com/en/rest/reference/users