oauthio-sample

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="coinbase-button" class="btn btn-block btn-social btn-coinbase">
  <i class="fa fa-coinbase"></i> Sign in with Coinbase
</a>

JavaScript

$('#coinbase-button').on('click', function() {
	// Initialize with your OAuth.io app public key
	OAuth.initialize('HwAr2OtSxRgEEnO2-JnYjsuA3tc');
  // Use popup for oauth
  OAuth.popup('coinbase').then(coinbase => {
    console.log('coinbase:', coinbase);
    // Prompts 'welcome' message with User's email on successful login
    // #me() is a convenient method to retrieve user data without requiring you
    // to know which OAuth provider url to call
    coinbase.me().then(data => {
    console.log('me data:', data);
      alert('Coinbase says your email is:' + data.email + ".\nView browser 'Console Log' for more details");
	  });
    // Retrieves user data from OAuth provider by using #get() and
    // OAuth provider url
    coinbase.get('/api/v1/users').then(data => {
      console.log('self data:', data);
    })    
	});
})