Search code examples
firebaseoauthgoogle-cloud-platformgoogle-oauthfirebase-dynamic-links

Why can't I add firebase dynamic url as allowed redirect_url for google oAuth?


I am working on a react-native based project where google made it frustratingly hard to implement their oAuth without using an SDK.

First of all, WebView is not allowed to oAuth. So I attempted to implement it through normal browser / chrome tab where redirect is my app id like com.myCompany.myApp but when I add this as allowed oAuth redirect url I get error in google cloud console that this is not a valid redirect id for web based project.

I then tried to set it up with firebase dynamic links, But when I save changes it errors with Request contains an invalid argument.


Solution

  • Different type of OAuth keys have different redirect requirements and best practices. It's too numerous to name them all, so please see this documentation.

    In general, if it's an installed app or a mobile app, the redirect URI isn't as important because you are just redirecting back to the app. However for web based app OAuth keys, you will need to be very careful with the redirect because it carries your access token. You can read more about redirect URIs and see what would qualify as a proper URI.

    Basically Google makes sure your URI seems ok for your OAuth key type, otherwise it will reject it.