javascripthtmloauthjanrain

Janrain custom buttons


I'm implementing Janrain and I want to use my own buttons. But when I click the button nothing happens. Here is my code:

<head>
        <script type="text/javascript">
        (function() {
        if (typeof window.janrain !== 'object') window.janrain = {};
        if (typeof window.janrain.settings !== 'object') window.janrain.settings = {};

        janrain.settings.tokenUrl = 'janrain/rpx-token-url.php';
            janrain.settings.appId = 'my app id here';
            janrain.settings.appUrl = 'https://loanerr.rpxnow.com';
            janrain.settings.providers = [
            'googleplus',
            'facebook',
            'linkedin'];

        function isReady() { janrain.ready = true; };
        if (document.addEventListener) {
          document.addEventListener("DOMContentLoaded", isReady, false);
        } else {
          window.attachEvent('onload', isReady);
        }

        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.id = 'janrainAuthWidget';

        if (document.location.protocol === 'https:') {
          e.src = 'https://rpxnow.com/js/lib/coacharabia/engage.js';
        } else {
          e.src = 'http://widget-cdn.rpxnow.com/js/lib/coacharabia/engage.js';
        }

        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(e, s);
        })();
        </script>
</head>

<body>
<div id="widgetContainer">
    <div id="facebook" class="idpButton social"><span class="fa fa-facebook fa-lg"></span></div>
    <div id="google" class="idpButton social"><span class="fa fa-google-plus fa-lg"></span></div>
    <div id="linkedin" class="idpButton social"><span class="fa fa-linkedin fa-lg"></span></div>
</div>

<script>
function janrainWidgetOnload() {
  // First, we construct an object to house all of our sign-in buttons
  var buttons = document.getElementsByClassName('social');

  // Then, we cycle through each button and attach each to a provider
  for (var b = 0; b < buttons.length; b++) {
    var button = buttons[b];
    janrain.engage.signin.triggerFlow(button, button.id);
  }
}
</script>
</body>

Solution

  • Triggerflow doesn't take those parameters, here's an example of how to use it:

    janrain.engage.signin.triggerFlow("facebook");
    

    or

    janrain.engage.signin.triggerFlow("googleplus");
    

    Each provider has a unique string/name assigned to it and that is how the social login workflow is initiated. You simply need to bind the button onclick handler accordingly.

    Hope this helps.