2
votes

I followed the instructions to configure the Enterprise Authentication in NativeScript Sidekick (https://docs.nativescript.org/sidekick/user-guide/enterprise-auth/oauth2?_ga=2.225672666.17995213.1561656859-952769349.1561656859) with my Azure AD B2C account.

I've locally built the application for Android and I run it on my phone using the preview app. It's working so far.

But every single time I try to login in the application, I've the following error: {"error":"invalid_client","error_description":"Client authentication failed.","debug":"Client Verification Failed: redirect uri not valid"}

I've looked at the configuration in Kinvey, I see the the redirect URI is http://example.com . In the procedure, modifying this URI is never specified, but maybe it's the problem. The thing is, I've no idea what I should put there instead since I want to redirect to my mobile app...

Any help would be greatly appreciated!

Edit: I've edited the call to loginWithMIC() to add parameters:

this._userService.loginWithMIC('nsplayresume://', 0, { micId: 'OAuth2:88b92d888ee44a36aea52fXXXXXXXX' })

Now I have this error: {"error":"invalid_client","error_description":"Client authentication failed.","debug":"Client Verification Failed: Error: Client is not configured for Kinvey Auth"}

Edit2: I've made some tests in the Kinvey Console, and using the Api Console of my application, I can succesfully login. So the configuration is good, it's the way I call it in the application that doesn't work for some reason...

If I call pingService.ping(), it's working fine, so my initialization seems good...

1

1 Answers

1
votes

Finally got it working... I've rolled back to the original loginWithMIC(null, null) call. The things that weren't working where the configuration in console.kinvey.com .

Here are my tips that are not in the step by step:

  • Add nsplayresume:// as a redirect URI for your service.
  • Test the App via the API Console to ensure that you can connect using MIC.

If this is working fine, the sample should work correctly.

Edit: If you want to get it working too once you installed the application, you need another redirect URI. nsplayresume:// is only for the NS preview app. You need to define an URI in your package.json like this:

{
  "android": {
    "v8Flags": "--expose_gc"
  },
  "main": "main.ns.js",
  "name": "migration-ng",
  "version": "4.1.0",
  "pluginsData": {
    "kinvey-nativescript-sdk": {
      "config": {
        "appKey": "kid_rkDJUINIQ",
        "appSecret": "17282f9d91da4af7b398855e32ea4dd0",
        "redirectUri": "sde://"
      }
    }
  }
}

Then you add this URI as antoher redirect URI for your service.