0

I have an application where people can have account say url is http://localhost:3000. People can also register their domain and have their separate workspace now the url for those users would be http://abc.localhost:3000, where abc is the personal domain user has.For normal flow I am able to successfully run things. I want to support subdomain urls like http://abc.localhost:3000 for google drive login. I was going through solutions already there, as app can support N number of subdomains so I cannot add different urls to redirect uri. So I need to have one uri. How can I have common redirect uri which can help me in both cases This is my code

            window.gapi.client
                .init({
                    clientId: googleDriveClientId,
                    scope: 'https://www.googleapis.com/auth/drive.readonly',
                })
                .then(() => {
                    this.auth = window.gapi.auth2.getAuthInstance();
                    this.handleAuthChange();
                    this.auth.isSignedIn.listen(this.handleAuthChange);
                });

With the above code I am able to login normally but for subdomain urls it gives me issue enter image description here

I tried to add redirect_uri: 'http://localhost:3000' to my init method but still get the same issue.I read about state property to carry subdomain value with it but this auth errors comes due to uri mismatch. Can someone help me to identify the code which I need to add to support subdomains ?

rishabh agarwal
  • 99
  • 1
  • 13
  • You need to add the exact URIs the application is gonna use as JavaScript origins. So in this case, you'd need to add a URI for each subdomain. – Iamblichus Aug 03 '21 at 08:36

1 Answers1

0

Answer:

You need to add the exact URIs the application is gonna use as JavaScript origins. So in this case, you'd need to add each subdomain manually.

Feature requests:

There are several related feature requests in Issue Tracker. Consider subscribing to them:

Related question:

Here is a similar question with a workaround, not sure if it will be feasible in your situation:

Iamblichus
  • 18,540
  • 2
  • 11
  • 27
  • I cannot add it manually as I won't be aware as when user create a separate subdomain and tries to use google login for that. Can't there be any solution that I can do at code level to support this ? – rishabh agarwal Aug 03 '21 at 10:03
  • @rishabhagarwal Not as far as I know. Take a look at the workaround suggested in the referenced question, not sure if it would be appropriate for your situation. – Iamblichus Aug 03 '21 at 10:21