If your codebase is in PHP and you would like user’s to be able to login to your site using GitHub (single sign-on) you can use the following as a good starting point:
Next you will need to setup an OAuth application within GitHub by doing the following:
- Login to GitHub.com.
- Go to your settings by clicking on your avatar image in the top-right corner of any GitHub page and then clicking on Settings in the drop-down menu.
- Scroll down to the Developer settings menu on the left and click OAuth Applications.
- Click the Register a new application button.
- Enter all of the necessary information to register your new OAuth application and then click Register application when you’re done.
Take the Client ID and the Client Secret and place them in the constants defined in your PHP code from the beginning of this post.
That should be it. Now when you run this code you should be prompted to authorize your application to read your public information and private email addresses. You can remove the scope if you don’t need to be able to read any private information such as email addresses or you can change the scope after reviewing this page. If you want more information about OAuth apps for GitHub you can check out this page.
Happy coding! 😎
Devanshu goyal · July 31, 2017 at 6:20 AM
Best of all the other scripts i found on web…
Harshvardhan Karn · January 18, 2018 at 3:21 AM