IBM MobileFirst Platform - 从适配器获取机密客户端令牌

IBM MobileFirst Platform - Get Confidential Client Token from Adapter

我正在使用具有推送通知功能的 IBM MobileFirst Platform 8.0 开发 iOS 应用程序

我已经设法通过邮递员发送通知,过程是

  1. 从移动优先平台服务器获取令牌
  2. 通过 rest api 与令牌一起发送到通知

我遵循的教程 link 是,

服务器端 - https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/sending-notifications/

客户端 - https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/handling-push-notifications/cordova/

获取令牌 - https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/authentication-and-security/confidential-clients/#obtaining-an-access-token

目前,我正在尝试在应用程序触发适配器调用时发送推送通知

我目前坚持使用 WL.Server.invokeHttp 获取令牌部分,下面是更多适配器代码和连接设置

function getToken() {
   var input = {
        method : 'post',
        returnedContentType : 'application/json',       
        path : '/mfp/api/az/v1/token',      
        headers : {
            Authorization:"Basic UHVzaE5asdasdas4444rrraWNhdGlvbjpQdXNoasdasd0aW9u",
            contentType:'application/x-www-form-urlencoded'
        },
        body:{
            grant_type : "client_credentials",
            scope : "push.application.my.app messages.write",

        }

    }; 

    var results =  MFP.Server.invokeHttp(input);
    return results;
}

<connectivity>
       <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>http</protocol>
            <domain>127.0.0.1</domain>
            <port>9080</port>
            <connectionTimeoutInMilliseconds>60000</connectionTimeoutInMilliseconds>
            <socketTimeoutInMilliseconds>60000</socketTimeoutInMilliseconds>
            <maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>
        </connectionPolicy>
    </connectivity>

希望得到指点,在此先感谢。

我设法用这些代码解决了它

var requestStructure = {
        method : 'post',
        returnedContentType : 'json',
        path : '/mfp/api/az/v1/token',      
        headers: {
            "Content-Type" : "application/x-www-form-urlencoded",
            "Authorization" : "Basic UHVzaE5asdasdas4444rrraWNhdGlvbjpQdXNoasdasd0aW9u"
        },
        parameters:{
            "grant_type" : "client_credentials",
            "scope" : "push.application.my.app messages.write"
        }
     };

    var results = MFP.Server.invokeHttp(requestStructure);
    return results;