nativescriptkinvey

Configuring OAuth 2 Authentication with NativeScript provided Enterprise Auth project template


I am Configuring OAuth 2 Authentication with NativeScript provided Enterprise Auth project template, I followed the complete guide to configure Azure Active Directory. After setting up URLs and keys when I am executing the application through tns preview, it is giving me following error:

https://auth.kinvey.com/v3/oauth/auth?client_id=kid_SJcDEau7N&redirect_uri=nsplayresume%3A%2F%2F&response_type=code&scope=openid

Error: {"error":"invalid_client","error_description":"Client authentication failed.","debug":"Client Verification Failed: redirect uri not valid"}

When I check the login script it was showing error because there was no argument given in the Kinvey.User.loginWithMIC() function so I provided Kinvey.User.loginWithMIC('http://example.com') as it was showing in the video tutorial.

login() {
    if (Kinvey.User.getActiveUser() == null) {
        Kinvey.User.loginWithMIC()
            .then((user: Kinvey.User) => {
                this.navigateHome();
                console.log("user: " + JSON.stringify(user));
            })
            .catch((error: Kinvey.BaseError) => {
                alert("An error occurred. Check your Kinvey settings.");
                console.log("error: " + error);
            });
    } else {
        this.navigateHome();
    }
}

as expected it should show the login screen for the account which I have configured in Azure Active Directory.


Solution

  • Here I have a NativeScript solution, which makes use of Kinvey's Mobile Identity Connect. It's basically built using the same template that you would like to make use of. There are couple of important steps, that you need to take care before running that project, they are as follows:

    For most up-to-date list of those crucial items, you can check out the repository's README file. Try that, and let me know if you can get Kinvey MIC working.