Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing Google Oauth 2.0 with localhost (June 2019)?

How do I test the Google OAuth 2.0 on my app with localhost, since Google requires a top private domain as the authorized domain?

a

I tried to look up solutions, but all the solutions given have been a while ago, and I think Google has changed their service since then.

like image 946
Katie Avatar asked Jun 04 '19 02:06

Katie


2 Answers

localhost is not a valid top-level domain, and it won't let you generate credentials without setting up a consent screen. You can add more than one authorized domain if you'd like, but you can't leave it empty. But you CAN delete the field if you have no domains / would not like to add domains for now. you just can't LEAVE it empty.

Notice the description -- "When a domain is used". so it's not an obligation to add authorized domain for consent screen. Moreover, the authorized domain here is only related with consent screen. Authorized origins and Authorized redirect URLs needs to be specified in the credentials part, which is all that matters; specifying the origin from which requests will be accepted and where it will be redirected. So just omit the authorized domain in the consent screen.

enter image description here

So how to delete it? Just in case if you haven't noticed, just hover over the field and this little man will pop up. delete it. that's all. Now you should be able to save and continue, where it might ask you to setup scopes.

enter image description here

I know it's really late, hoping it might help others..

like image 177
Aniket Kariya Avatar answered Sep 23 '22 18:09

Aniket Kariya


After about an hour banging my head against the wall I found this article that has a step by step solution that works (as of July 2020).

Basically you need to create a service account, share the sheet with that account, and then it should work.

All of the other auth methods I tried either raised nonsense errors, or simply silently didn't work.

like image 24
sapo_cosmico Avatar answered Sep 26 '22 18:09

sapo_cosmico