Allows CodeIgniter to let users login to GitHub and gain access to their account data and the rest of GitHubs API.
- You first need to register your application with GitHub to get your
client_id
andclient_secret
- Drag and drop the files in the respective folders (e.g. config/github.php goes into the config file in the CI application)
- Set the config variables
- Create button with link generated by
$this->github->generateLoginURL()
- Create the redirect URI page, an example of how this could look is below:
public function github_oauth(){
$this->load->library('github');
$token = $this->github->getAccessToken();
if($token == false){
//something went wrong
redirect('login','refresh');
}
//save token somewhere safe
redirect('','refresh');
}