oauthio-sample
by a13xs
HTML
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdn.rawgit.com/oauth-io/oauth-js/c5af4519/dist/oauth.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-social/4.12.0/bootstrap-social.min.css">
<a id="instagram-button" class="btn btn-block btn-social btn-instagram">
<i class="fa fa-instagram"></i> Sign in with Instagram
</a>
JavaScript
$('#instagram-button').on('click', function() {
// Initialize with your OAuth.io app public key
OAuth.initialize('e9a75c19474c4f11956b67cb980388e7');
// Use popup for OAuth
OAuth.popup('instagram').then(instagram => {
console.log('instagram:', instagram);
// Prompts 'welcome' message with User's name on successful login
// #me() is a convenient method to retrieve user data without requiring you
// to know which OAuth provider url to call
instagram.me().then(data => {
console.log('me data:', data);
alert('Instagram says your name is ' + data.name + ".\nView browser 'Console Log' for more details");
});
// Retrieves user data from OAuth provider by using #get() and
// OAuth provider url
instagram.get('/v1/users/self').then(data => {
console.log('self data:', data);
})
});
})