17

I am trying to integrate Google login in my website ..

I am following this example: https://developers.google.com/identity/sign-in/web/

I generated client id for my project and replaced it in above code, I keep getting this error:

  1. That’s an error.

Error: invalid_request

Permission denied to generate login hint for target domain.

VC1
  • 1,660
  • 4
  • 25
  • 42
CKS
  • 497
  • 3
  • 9
  • 16

5 Answers5

41

I ran into this issue while doing local development. Make sure when running your project locally that you launch "http://localhost" rather than "http://127.0.0.1", "http://0.0.0.0", etc...

Mikaël Mayer
  • 10,425
  • 6
  • 64
  • 101
kevinstueber
  • 2,926
  • 3
  • 26
  • 26
  • 1
    it happens to me as well. Switch to localhost and can work well now.Thank you for this tip – Chris Bao Dec 14 '15 at 06:27
  • Same here. I switched to "localhost" from "0.0.0.0" and it worked. – Ethan Chen Jul 13 '16 at 22:41
  • if you want to access it from local network (eg. from your iphone or ipad) you might check the answers here: https://stackoverflow.com/questions/24736168/error-invalid-request-device-id-and-device-name-are-required-for-private-ip/30068100#30068100 – PEZO Apr 06 '19 at 19:50
  • I was using browser based web authentication. So in addition to running project via 'http://localhost:port_number" I also had to add 'http://localhost:port_number' in the developer console under 'API and Services' -> 'Credentials' -> 'Client Id for Web Application' -> 'Authorised Javascript Origins' (port_number : is your port number where your local server is running) – utkarsh-k May 14 '21 at 19:56
4

For me, I had to the developer console, to the project which was using the analytics api, and then I had to add localhost:port to both the "authorized Javascript origins" and the "authorized redirect URIs". In my scenario I was using port 9002 How to

Bren1818
  • 2,612
  • 1
  • 23
  • 28
  • 3
    For the "Authorized redirect URIs," if I do what you did here, I will get an error saying "Invalid Redirect: http://localhost:9002 must end with a public top-level domain (such as .com or .org)." – Ethan Chen Jul 13 '16 at 22:15
  • Apparently this combination of redirects & authorizaed JS urls works for me, take in mind that there is a (undefined) delay after set the new domains (localhost, development, production). It's so annoying but the documentations from Google are not too well defined. – Franco Gil Dec 06 '21 at 19:43
1

Just my 2 cents. I am on a local developer machine behind Browsersync proxy. I could only make it work using the non-proxied localhost name defined in etc/hosts file like this: 127.0.0.1 my-site.localhost.

Then I put http://my-site.localhost into 'Authorized Javascript origins' field and http://localhost into 'Authorized request URIs' one.

Then the error disappeared and authorization worked.

Valentine Shi
  • 6,604
  • 4
  • 46
  • 46
0

If you are using actual IP address(http://your IP address:8080/) for redirect URL, then it would throw this error. Google auth API only accept domain name as(www.mydomain.com) redirect URL.

  • if you want to access it from local network (eg. from your iphone or ipad) you might check the answers here: https://stackoverflow.com/questions/24736168/error-invalid-request-device-id-and-device-name-are-required-for-private-ip/30068100#30068100) – PEZO Apr 06 '19 at 19:49
0

Try the following dns name localtest.me for local development.

Pratik Sharma
  • 165
  • 2
  • 9