angularwebsphereibm-mobilefirst

Invalid request body - JSON mapping failed for WLAuthorizationManager.obtainAccessToken in IBM MobileFirst 8.0


I'm using Angular with IBM MobileFirst 8.0. I'm facing an issue with WLAuthorizationManager.obtainAccessToken()

I am using the below code.

WLAuthorizationManager.obtainAccessToken()
    .then(
        function (token) {
          console.log(token);
        },
        function (res) {
          console.log(res);
        })

However, I'm always getting the below error.

Response:

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

Version Details:

cordova-plugin-mfp: 8.0.2021031007

ibm-mfp-web-sdk: 8.0.2021011205

The project is already created in mfp console.

Any help will be appreciated. Thanks!


Solution

  • The 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.

    This is necessitated by the APAR PH30473 STRENGTHENING PRE-AUTH ENDPOINT, which makes changes in the communication protocol between the Mobile Foundation SDKs and the Mobile Foundation server.

    If you are unable to upgrade your server, as a compatibility measure, you can choose to use the newer SDKs (version 8.0.2020101412 or higher) with an older version of the Mobile Foundation server (versions prior to 8.0.2020101311) by adding the following configuration:

    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.