Sign with Apple JS issue

2.1k Views Asked by At

I'm having one issue with sign in with Apple. The pop up gets closed after the successful login but in response I get

{"isTrusted": false} Wondering what I'm missing

I have already added the sub domain and domain details in the redirect URL and my redirect URL is same as the page from which the pop up was opened.

Here is my code for more details

scriptjs.get('https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js', () => {
    const params = {
        clientId: '*',
        redirectURI: '*',
        scope: 'name email',
        usePopup: true,
    };
    window.AppleID.auth.init(params);
});

I initiate this process on button click

handleClick={() => window.AppleID.auth.signIn()}

And listen for the response via listeners

        //Listen for authorization success
        document.addEventListener('AppleIDSignInOnSuccess', (data) => {

                //handle successful response
                alert(JSON.stringify(data));
                // here Im getting {"isTrusted": false}

                alert("Success");
        });

        //Listen for authorization failures
        document.addEventListener('AppleIDSignInOnFailure', (error) => {

                //handle error.
                alert(JSON.stringify(error));
        });

Any idea what does isTrusted false means?

2

There are 2 best solutions below

0
On

If found a solution after hours of debugging the response won't be printed in alert instead you can go with following solution to print it in console.log

        //Listen for authorization success
        document.addEventListener('AppleIDSignInOnSuccess', (data) => {

                //handle successful response
                console.log(data);
                alert("Success");
        });
0
On

This may help you guys

Make sure that the redirectURI starts with "https://"

Also make sure the redirectURI matches correctly to the webpage that initiated the popup.

If you have multiple places from where you're signing in, add all those RedirectURI's separating them with commas