MongoDB.live, free & fully virtual. June 9th - 10th. Register Now MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Google Auth linking with Anon account

So, I have issue with linking my anonymous user accounts with Google provider. My process is following:

// 1) Anon user is created
if (!client.auth.isLoggedIn) {
 const user = await this._auth.loginWithCredential(new AnonymousCredential())
}

// 2) When user decide to login, I try to link them like that
this._auth.user.linkUserWithRedirect(new GoogleRedirectCredential()).then(user => console.log("I AM BACK", user)).catch(console.error)
// ^ this fails with following error
//{
// error: "error exchanging access code with OAuth2 provider",
// error_code: "AuthError",
// link: "https://stitch.mongodb.com/groups/5d61344a9ccf6410569421c3/apps/5d617ecc552b569688b8acf8/logs?co_id=5ebe9bec77b63e267d604a01"
// }

// 3) I've found out on stack overflow that adding url to provider could solve that but I get CORS error if I try to do this
this._auth.user.linkUserWithRedirect(new GoogleRedirectCredential(window.location.href)).then(user => console.log("I AM BACK", user)).catch(console.error)
  1. I’ve also read that it may be because client IDs and secret IDs doesn’t match but I made sure 2 times that value here
    https://console.cloud.google.com/apis/credentials/oauthclient/XXX
    Are exactly the same as ones here
    https://stitch.mongodb.com/groups/XXX/apps/XXX/auth/providers/oauth2-google

Any idea what could still be wrong?