ibm-mobilefirst - 在 IBM Worklight 中授权 HTTP 适配器

标签 ibm-mobilefirst

我正在努力让 HTTP 适配器请求到 protected rss 提要以正确执行。我已经阅读了大量 IBM 的文档,并寻找已移动或“正在维护”的 IBM 页面的死链接。不幸的是,我找到的所有示例都没有说明如何授权此请求。

为了这个示例,我尝试从 IBM Greenhouse Environment 中的 Connections 安装访问 rss 提要。

适配器 XML:

<?xml version="1.0" encoding="UTF-8"?>
<wl:adapter name="exampleAdapter"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:wl="http://www.worklight.com/integration"
    xmlns:http="http://www.worklight.com/integration/http">
    <displayName>feedRead</displayName>
    <description>feedRead</description>
    <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>https</protocol>
            <domain>greenhouse.lotus.com</domain>
            <port>443</port>
        </connectionPolicy>
        <loadConstraints maxConcurrentConnectionsPerNode="2" />
    </connectivity>
   <procedure name="getFeed" connectAs="server"/>
</wl:adapter>

适配器.js:

function getFeed() {
    var input = {
        method : 'get',
        returnedContentType : 'xml',
        path : 'connections/opensocial/basic/rest/activitystreams/@me/@all/@all?    rollup=true&format=atom'
    };
    return WL.Server.invokeHttp(input);
}

如何传递访问此 Feed 所需的凭据?

谢谢!

最佳答案

您可以将身份验证机制指定为适配器 XML 文件的一部分。文档在这里:The Authentication element of the HTTP adapter .

目前我面前没有要检查的 Worklight Studio 实例,但我想应该有适配器 XML 的设计 View 或一些自动完成功能来帮助填写详细信息的指定方式在<authentication> block 。

示例:

<?xml version="1.0" encoding="UTF-8"?>
<wl:adapter name="exampleAdapter"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:wl="http://www.worklight.com/integration"
    xmlns:http="http://www.worklight.com/integration/http">
    <displayName>feedRead</displayName>
    <description>feedRead</description>
    <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>https</protocol>
            <domain>greenhouse.lotus.com</domain>
            <port>443</port>
            <authentication>
                <basic/>
                <serverIdentity>
                    <username> ${user} </username>
                    <password> ${password} </password>
                </serverIdentity>
            </authentication>  
        </connectionPolicy>
        <loadConstraints maxConcurrentConnectionsPerNode="2" />
    </connectivity>
   <procedure name="getFeed" connectAs="server"/>
</wl:adapter>

关于ibm-mobilefirst - 在 IBM Worklight 中授权 HTTP 适配器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16921978/

相关文章:

android - IBM Mobile First - Json Store 无法在 Samsung Galaxy S6 上运行

javascript - Worklight 或 jQuery Mobile 意外抛出 “pagechange” 事件

ibm-mobilefirst - IBM Worklight - 如何在启动或运行时动态更改适配器从客户端连接到的域/主机名?

java - 使用 IBM MobileFirst Platform Foundation 生成的 Android 应用程序中的单元测试 Java 代码

cordova - 添加 MobileFirst 插件时,为 Windows 10 构建 ionic 应用程序失败

ibm-mobilefirst - cookie 中缺少安全属性 : WL_PERSISTENT_COOKIE and testcookie

ios - IBM Worklight 6.0 - v6.0.0.20130614-0631 是否不支持 iOS7 部署?

mysql - Bluemix - 将 Mobilefirst 容器绑定(bind)到 Cloud Foundry 应用程序

ios - IBM Worklight - WL.App.getDeviceLanguage() API 方法在 iOS 中不返回正确的语言代码

android - 为什么 Worklight 应用程序需要 Worklight Server?