Is there any documentation about using github to authenticate users on my site? Preferably in PHP.
Like the button here: http://coderwall.com/
Yes, it's documented in the OAuth section of the GitHub API documentation.
There's also an example implementation in Github's documentation guides.
The example provided by Github and shared by Adrian Petrescu is great and is as simple as it gets.
However, I find that most OAuth examples are missing 2 things:
So we created this jsfiddle (https://jsfiddle.net/dg9h7dse/30/), with accompanying detailed explanation here on coderwall. You can use this immediately to test out an OAuth provider's API endpoints.
I'll summarize it here:
To create a nice social button
```
<a id="github-button" class="btn btn-block btn-social btn-github">
<i class="fa fa-github"></i> Sign in with GitHub
</a>
```
NOTE: https://oauth.io is a paid-service but lets you integrate with hundreds(?) of OAuth providers without writing backend code.
All we need to do then is to bind our nice social login button to a Javascript snippet that calls the OAuth service provider.
```
$('#github-button').on('click', function() {
// Initialize with your OAuth.io app public key
OAuth.initialize('YOUR OAUTH.IO PUBLIC KEY');
// Use popup to prompt user for their OAuth provider credentials
OAuth.popup('github').then(github => {
// If login is successful,
// retrieve user data from oauth provider
console.log(github.me());
});
})
```
Hope this helps more people to understand and get started on using OAuth.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With