46

I have installed the Google Drive Realtime API sample files on my web server, following these instructions, including generating a client_id in the Cloud Console and inserting it into the index.html file.

When I visit that page and click the button to authorize the app, it pops up with a new window and shows:

Error: invalid_client
no registered origin

The Request Details are:

openid_connect_request=true
cookie_policy_enforce=false
scope=https://www.googleapis.com/auth/drive.install https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/plus.me
response_type=token
access_type=online
redirect_uri=postmessage
proxy=oauth2relay865404532
origin=http://mywebsite.com
state=264939258|0.165356673
display=page
client_id=1077585001321.apps.googleusercontent.com
authuser=0

I can't see any other client_id that I should be using in the Cloud Console. Does anybody know how to overcome this error? Thanks for your help.

ashatte
  • 5,442
  • 8
  • 39
  • 50

2 Answers2

60

In the new Google API Console, configure your OAuth2.0 authorized origins from

Your Project > APIs & auth > Credentials

You might need to add a new Client ID specifically for a web application (I did because the default was for AppEngine)

Create Client ID > Web Application > Authorized Javascript origins

If you are running on a local dev server, just add the exact URL such as :

http://127.0.0.1:9000
Johno Scott
  • 1,730
  • 18
  • 13
  • 1
    I would like to know about 'how to enter the localhost url for Authorized JavaScript origins'.since I was working on localhost machine and after entering the localhost url as 'http:127.0.0.1/myProjectName' it throws 'Origin URIs must not contain a path: http://127.0.0.1/myProjectName/' – Nagama Inamdar Mar 20 '14 at 07:52
  • 2
    You would just say 'http://localhost:13091' (whatever your localhost is) without mentioning your project name - worked for me! Thanks for this answer! – sim1 Jul 06 '14 at 18:26
  • in case it helps at all - I had trouble following the above instructions. the problem for me was that in the OAuth credential config, the field "Authorized JavaScript origins" was not set. I set it to match the exact dev URL: "http://127.0.0.1:8080" I guess when you deploy to a real web server, you need to make a new client Id with the appropriate URL – Sean Jan 12 '16 at 11:20
  • It seems it takes time for the google to apply these settings - at least when adding additional origin - it was giving not-a-valid-origin error for 5-10 min before finally accepting it – Dmitry Yudakov Mar 01 '17 at 08:44
14

UPDATE: I changed accepted answer to Johno Scott instead as he refers to the newer version of the console, whereas mine was only true for the older version.


I solved it. I needed to enter a WEB ORIGIN on the OAuth 2.0 Client ID screen. Specifically, it had to be the exact path/url of the index.html file, otherwise it defaults to the root domain which doesn't work.

This screenshot shows you exactly where it needs to be entered:

enter image description here

ashatte
  • 5,442
  • 8
  • 39
  • 50