无效的请求正文-IBMMobileFirst8.0中WLAuthorizationManager.obtainAccessToken的JSON映射失败
我在 IBM MobileFirst 8.0 中使用 Angular。我正面临 WLAuthorizationManager.obtainAccessToken() 的问题
我正在使用下面的代码。
WLAuthorizationManager.obtainAccessToken()
.then(
function (token) {
console.log(token);
},
function (res) {
console.log(res);
})
但是,我总是收到以下错误。
回复:
errorCode: "400"
errorMsg: "Bad Request"
responseHeaders: {cache-control: "[no-store, no-cache, must-revalidate]", connection: "[close]", content-language: "[en-US]", content-security-policy: "[default-src 'self';]", content-type: "[application/json]", …}
responseText: ""Invalid request body - JSON mapping failed.""
status: 400
statusText: "Bad Request
版本详情:
科尔多瓦插件-mfp:8.0.2021031007
ibm-mfp-web-sdk:8.0.2021011205
该项目已在 mfp 控制台中创建。
任何帮助将不胜感激。谢谢!
回答
iFix 8.0.0.0-MFPF-IF202010151343 introduces a breaking change with respect to compatibility with older versions of the Mobile Foundation server. If your app uses any of the following SDKs - Android, iOS or Cordova version 8.0.2020101412 or higher, it is necessary to upgrade your server version to 8.0.2020101311 or higher.
这是APAR PH30473 STRENGTHENING PRE-AUTH ENDPOINT所必需的,它更改了 Mobile Foundation SDK 和 Mobile Foundation 服务器之间的通信协议。
如果您无法升级您的服务器,作为兼容性措施,您可以通过添加以下配置:
Native Android apps
Add the following line to your mfpclient.properties file:
sdkProtocolVersion=1
Native iOS apps
Add the following entry to your mfpclient.plist
Name - sdkProtocolVersion
Type - Number
Value - 1
Cordova apps
Add the following line under the section of your project's config.xml.
mfp:SDKProtocolVersion1</mfp:SDKProtocolVersion>
The recommended approach is to upgrade the server and not use the compatibility configuration mentioned above.
Web Apps :
add sdkProtocolVersion : '1' in wlInitOptions
For more details see here https://mobilefirstplatform.ibmcloud.com/blog/2018/05/18/8-0-master-ifix-release/#changes-in-this-ifix-4
To resolve your issue :
Connect app with new version of app + set sdkProtocolVersion to 1
Or
Upgrade server to latest version.