September 10, 2014 1:05 am

How to Add Github oAuth login on your website using PHP

In this tutorial I am going to show you that how you can add Github oAuth login system in your PHP websites and its very easy and simple to integrate, Github.com is a very important service for developer’s. It will help your users for easy login without writing login forms just in one click and user logged in. We have many other one click login systems with Facebook, Google, Linkedin and Microsoft you can use them also.

How to Add Github oAuth login on your website using PHP

First of all you need to create Github application

Register Application Click Here [see image]

Developer applications

Fill out application Form [see image]

Register a new OAuth application

Application Details

After Submitting this form you will get Client ID and Client Secret [see image]

PHPGang Github application

githubConf.php

This file contains github application Client ID and Client Secret.

index.php

This file contains PHP Code to get account code, access token and user information and display.

First of all it shows you a Github login button when you click on that button it will take you to the github authentication page once you authorize application it return with the code in query sting on your callback url you defined in your application. Using that code and application Client ID and Client Secret to this url (https://github.com/login/oauth/access_token) and  we get access token, using that access token we can get users information like name, email, location etc.

That’s all for today’s tutorial I hope you like this tutorial so please don’t forget to give your feedback and share issues if you faced in its integration. Do share with your friends.

Author Huzoor Bux

I am Huzoor Bux from Karachi (Pakistan). I have been working as a PHP Developer from last 5+ years, and its my passion to learn new things and implement them as a practice. Basically I am a PHP developer but now days exploring more in HTML5, CSS and jQuery libraries.


Tutorial Categories:
  • kapil garg

    Awesome article.. Thanks for the code and the working demo..