TL;DR -- When creating a new Chrome Extension OAuth credential in GCP, you are only prompted for the extension ID from the Chrome store. Is it possible to find out what value is assigned (if any) to the redirect_url property of this new credential?
I am attempting to create a Chrome extension that can connect to Google APIs, to automate some productivity things. This is not an existing extension where something has gone wrong. I'm essentially following this doc, to wire this up for the first time.
I'm at a point where I'm trying to get a token to make API requests. After a bit of troubleshooting, I ended up at a place where I'm getting an error that tells me my redirect URL does not match.
The redirect URL I'm passing comes from the `getRedirectURL()` Chrome API call. I am assuming that is what the redirect will be because the GCP console UI to create the new Chrome Extension credential doesn't have a field to specify the redirect URL.
So, is there a default redirect URL assigned to new Chrome Extension credentials? Is there a way I can see what the redirect on this credential is?
I've tried to *not* send the param, but I get an error (expectedly).
I've also tried to send weird values like `localhost` or empty string and I get a security error (again, expectedly).
It's also possible I've missed something in this scaffolding that hasn't occurred to me yet.
Any insight into this would be much appreciated.
Thanks for reading.
Hello @darthgoon ,
For the credential, once created, you just need to provide your extension ID from the Chrome store. Then Google Cloud Platform automatically constructs the redirect URL using the following format:
https://<extension_id>.chromiumapp.org/
Where you replace <extension_id> with your actual Chrome extension ID.
Inspecting the Chrome Extension Code. Open your extension's source code and look for the call to
chrome.identity.launchWebAuthFlow
This function takes an object as an argument,usually called
authoptions
Within authOptions, search for a property named redirectUri. This value will be the automatically generated URL.
2. You can try using Chrome Network Inspector. You just need to enable the developer mode in your Chrome browser. Then access your extension's options page or trigger the OAuth flow in your extension . Open the Chrome Devtools and switch to the "Network" tab. Filter the requests by your extension's domain. And then look for a request with the OAuth authorization code in the response URL. The URL preceding the code will be the redirect URL.