Search code examples
google-analyticsauthsub

AuthSub target path prefix does not match the provided "next" URL


We have this web app where every customer hook up their own domain/use a sub domain to our domain, for their account. This account can be integrated with Google Analytics for statistics.

Our problem is with the AuthSub authentication. To often, when we redirect the user to sign in on Google, they are presented with the error AuthSub target path prefix does not match the provided "next" URL..

In accordance with this question I changed the next URL to a non-restricted with no redirects, but it didn't solve the issue.

As I understand it I can't register our app with Google, since every customer have their own unique domain (though most have a *.our-app.com).

What more can I try? Thank you.

Edit: This is the full error message.

The page you have requested cannot be displayed. Another site was requesting access to your Google Account, but sent a malformed request. Please contact the site that you were trying to use when you received this message to inform them of the error. A detailed error message follows:

AuthSub target path prefix does not match the provided "next" URL.


Solution

  • Solved it. I created a common domain for all redirects from Google (which is used in the next parameter), which I registered with Google.

    So if the user had the domain "client.app.com", the next parameter would look something like this: core.app.com/savetoken?domain=client.app.com. This page simply redirects to client.app.com/savetoken with the token from Google.