I'm very new to chrome extension development. I'm trying to integrate google authentication to a chrome extension that I'm building. First, I added google auth using a OAuth client ID of type "Chrome Extension" that doesn't require you to enter your redirect URI when setting up. When trying to sign in with the extension, I get the pop-up for google login with the following error:

You can’t sign in because this app sent an invalid request. You can try again later or contact the developer about this issue.

If you are a developer of this app, see error details.

Error 400: redirect_uri_mismatch

I've checked hundreds of times and found that the redirect URI is correct. I've checked the extension ID and found it the same. I'm using the code chrome.identity.getRedirectURL() to get the redirect URI and it returns the correct URI. I've tried passing the redirect URI to the web auth flow encoded as well but no luck and the error is persistent.

To try a different approach, I've created an OAuth Client ID of type "Web Application" which explicitly requires you to enter the redirect URI at the time of creation. But the error is the same and persistent.

I'm not sure at this point what else I can try. I'd appreciate any help regarding this. Also, I'm not sure what other information I can provide but let me know what other information you'd need. I have mostly used this tutorial to implement oauth using "Web Application" method.

Thanks,

1

There are 1 best solutions below

2
ade19 On

Follow this guide instead to integrate Google Identity services into your Chrome extension. The launchWebAuthFlow() method enables auth flows for non-Google identity providers. You should be using the getAuthToken() method instead which delivers the OAuth 2.0 response directly to your app and doesnt require you to provide a redirect URI.