I'm working in Phonegap and have implemented an OAuth sign-in using Google login. I used the code from this SO question: How to use Google Login API with Cordova/Phonegap.
But after I set my redirect_URI to localhost, my phone gives me an error and closes the app right after the consent screen, saying this.
I believe the issue is that my phone doesn't have a localhost URL, so it doesn't understand the reference. However, every guide I've found says to set the redirect_URI to localhost.
I have set the redirect_URIs in the Google Developer Console here. They match the redirect_URI in my code, here:
redirect_uri: 'http://localhost',
So I know there's no mismatch.
I'm using an InAppBrowser window for the authentication. When I run it on a server on my computer (using ionic serve) and set the redirect_URI to localhost:8100 (the port of the server), it works fine because localhost:8100 actually exists for the computer. I can't set the redirect_URI to a page in my app as far as I know because the Developer's Console only allows certain URLs.
How can I allow my app to return to its previous page after the consent screen on my phone?
I've also been trying to automatically close the InAppBrowser window after the consent screen, but window.close()
doesn't work. Getting that to work may be a work around for the fact that I can't redirect back to my app after login.
It worked when I upgraded cordova version, the code found in the link How to use Google Login API with Cordova/Phonegap works fine for me in cordova 4.0.0. Unsure if it is the Problem of inappbrowser plugin in 2.9.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With