Search code examples
javaoauthxpagesibm-connectionsibm-sbt

Error getting Connection Cloud data using Xpages and IBM SBT


I'm trying to connect to Connections Cloud to get data and display it in xpages using IBM SBT, but I'm having some troubles. I have installed the IBM SBT on Domino Server and deployed it to Domino Designer after reading the installation guide.

I have also a smartcloud account, where I have registered an internal app for OAuth testing.

Internal app credentials

I created a new nsf application, copied the managed-beans from the sample XPagesSBT.nsf database and replace the OAuth1 credentials. The faces-config.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
    <!--
        Token store Memory implementation
    -->
    <managed-bean>
        <managed-bean-name>CredStore</managed-bean-name>
        <managed-bean-class>com.ibm.sbt.security.credential.store.MemoryStore
        </managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    <!--
        SmartCloud 
   -->
    <managed-bean>
        <managed-bean-name>connections</managed-bean-name>
        <managed-bean-class>
            com.ibm.sbt.services.endpoints.SmartCloudOAuthEndpoint
        </managed-bean-class>
        <managed-bean-scope>application</managed-bean-scope>
        <!-- Endpoint URL -->
        <managed-property>
            <property-name>url</property-name>
            <value>https://apps.na.collabserv.com
            </value>
        </managed-property>
        <managed-property>
            <property-name>serviceName</property-name>
            <value>SmartCloud</value>
        </managed-property>
        <!-- OAuth parameters -->
        <managed-property>
            <property-name>credentialStore</property-name>
            <value>CredStore
            </value>
        </managed-property>
        <managed-property>
            <property-name>requestTokenURL</property-name>
            <value>https://apps.na.collabserv.com/manage/oauth/getRequestToken
            </value>
        </managed-property>
        <managed-property>
            <property-name>authorizationURL</property-name>
            <value>https://apps.na.collabserv.com/manage/oauth/authorizeToken
            </value>
        </managed-property>
        <managed-property>
            <property-name>accessTokenURL</property-name>
            <value>https://apps.na.collabserv.com/manage/oauth/getAccessToken
            </value>
        </managed-property>
        <managed-property>
            <property-name>appId</property-name>
            <value>app_20051314_...</value>
        </managed-property>
        <managed-property>
            <property-name>consumerKey</property-name>
            <value>3f1b3f22658601...
            </value>
        </managed-property>
        <managed-property>
            <property-name>consumerSecret</property-name>
            <value>bcb4ca1d1ede5...
            </value>
        </managed-property>
    </managed-bean>
</faces-config>

I selected the Xpage Libraries to use and finally I created an Xpage based on this Snippet taken from Greenhouse:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

    Here is the list of public Communities:
    <xp:br></xp:br>
    <xp:br></xp:br>
    <xp:text escape="false" id="computedField1">
        <xp:this.value><![CDATA[#{javascript:var svc = new com.ibm.sbt.services.client.connections.communities.CommunityService()
var c = svc.getPublicCommunities()
if(c.size()>0) {
var result = ""
for(var i=0; i<c.size(); i++) {
result += "<b>Name:</b>"+c[i].getTitle()+"<br/>\n"
}
return result;
} else {
return "No Result";
}}]]></xp:this.value>
    </xp:text>
</xp:view>

When I open the Xpage, it redirects me to the Authentication page for Connection Cloud, then redirects to the Grant Access page and finally redirects to my Xpage with this error:

Error while calling java constructor 'com.ibm.sbt.services.client.connections.communities.CommunityService()' (java.lang.reflect.InvocationTargetException).

The server release is 9.0.1FP4 on Windows/Longhom/64 6.1 and runs under https. I don't know what I'm missing. Maybe something at server level?. I would appreciate any help. Thanks.


Solution

  • I solved it

    I had installed the latest release of the SBT SDK from github (1.1.11.20151208-1200). I uninstalled it and instead install the openntf release (1.0.3.20140723-1200). Now it works fine.