5 Replies Latest reply on Apr 21, 2014 9:08 AM by Ryan Rutan

    Webhooks and Jive Communities

    pcrownov Beginner

      Hey, (TL;DR at bottom)

         I have been playing around for a while with the sdk and am having an issue understanding Jive Communities and the role they play with webhooks. I will lay out what I am trying to do first to give context.


      I want an application that will be notified via webhook that a user has modified their profile. Then based on that information I want to grab the users information in a secondary call (since the modified fields aren't included in the webhook response... v4 ? ) and then push that data into our LDAP system. The purpose is to keep 3rd party applications from modifying our LDAP but to also keep Phone numbers/address's/etc... in sync between the two systems. Now for what I have been doing so far.


      I started out in Jive v7.0.0.1 and with a starter app that made no use of the jive-sdk, made direct calls to the REST api to register a webhook. This took a bit of finagling but I finally got the system to work and return a call to me when a user was created or deleted but not on profile modification. For this I found that specific verb was added in v7.0.1 so I of course, upgraded my system. After the upgrade I reinstalled the app and saw the correct verb coming across, horray! But then I realized that I needed another call, changed something in the app and removed the db * extension.zip (which I had not done since before the upgrade) and on re-installation of the app, Jive refused to register it. So I turned to the examples and to the community to learn, which all used the sdk...


      After a few days of figuring out how the nodejs jive-sdk module works, I thought I had finally figured things out. I created an app with the correct directory structure, created a services.js file and in it, the exports.onBootstrap call that would register my webhook. After installing the app to Jive and seeing the instance come through in the console, I saw this error:


      "Error: Failed to create community webhook. No access token associated with community, and none provided explicitly."


      I can't find anything in the community with that error message or anything with parts of it so I tried using one of the pre-built jive-sdk examples with webhooks.... after adding callbacks for success and error to the webhook registration I saw the exact same error! Thus, I have come to the conclusion that I do not understand what the "community" property in the webhooks is for or how to properly use it. And yes, it is a fairly explanatory error, but I don't know what is defined as a "Community" or where I would set an access token on it and Jive searches were not helping in the least.


      TL;DR: Got the above bolded error when trying to register a webhook through my own app and through the "example-auth" app when adding callbacks to the webhook registration. Not sure if I am missing something like a setting or am confused on the overall way that the system should work.


      Any help would be greatly appreciated as I am fairly lost at this point... Thanks!

        • Re: Webhooks and Jive Communities
          Ryan Rutan Guru

          Patrick Crownover - From what you've described, it sounds like you have a perfect understanding of how the WebHooks work, I think you might just be working through some environment issues with your jive-sdk. 


          One example that you can look at is the example-auth in the jive-sdk:

          jive-sdk create example-auth --name=patrick-test


          if for no other reason it will be another canvas of code to look at, but it works semantically the same. 


          The community parameter is basically a construct that has all the OAuth creds and tokens for the community, thus when passed into the method, the method can determine which OAuth creds (code, clientId, clientSecret) to use for the call.  Thus, if in your db folder, the community.json file should have an entry that lines up with your registered community and has the above fields.


          If you are not seeing those fields in the community.json, then that is definitely the problem, and I would wipe your DB and re-register with the add-on.  If you do not see those fields, then that is the problem...but from what I am seeing your understanding of WebHooks is solid. 


          Let me know if you get your example working, and I think we might be able to work out a game badge =)

          1 person found this helpful
            • Re: Webhooks and Jive Communities
              pcrownov Beginner

              Hey Ryan Rutan,

                 Thanks for the reply and information! I had actually already tried using the "example-auth" sample application in the jive-sdk. I realize it was kind of hidden in my original post, sorry about that. When I tried using that example I was presented with the same error upon the system trying to register the webhook.


              However, to make a long story short, I just discovered that I couldn't use the basic authentication for the system and had to use the SIGN feature for the extension to register against. Once I found the uuid and created the JiveServiceSignature, I was able to successfully register the webhooks!


              For those that may want information about this error in the future:


              1. create your app and run it for the first time
              2. go to /db/jiveExtension.json and copy the uuid
              3. go to jiveclientconfiguration.json and create or update the "uuid" property within the "extensionInfo" object to the uuid found in step 2
              4. go to the Add-ons section of Jive and ctrl+click on the "Upload Package" button. This should open up an area that you can Sign the package with
              5. paste the uuid into the textbox and click "Sign"
              6. copy the signature
              7. go to jiveclientconfiguration.json and create or update the "jiveServiceSignature" property within the "extensionInfo" object to the signature from step 6
              8. stop your application and remove the db and extension.zip folders
              9. re-run your application
              10. install your app using the Add-ons section and it should be registered!