5

I am trying to run the quick start code of Real Time API of Google Drive. I believe I did everything right. But I am getting

Error: origin_mismatch

Request Details

    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=oauth2relay601571239
    origin=http://127.0.0.1
    state=811328575|0.818765953
    display=page
    client_id=XXXXXXXXXX
Frodo Baggins
  • 8,290
  • 6
  • 45
  • 55
Rahul
  • 739
  • 4
  • 15
  • 31

2 Answers2

9

You haven't given much detail about your application architecture, so i can only suggest a general answer. OAuth restricts which URLs can be referred to it. The list of permitted URLs is configured in the API console at https://code.google.com/apis/console. The URL is very fussy, so make sure you enter it exactly as it appears in the address bar.

As at Oct 2013, you can't use localhost. You have 2 choices.

  1. edit 127.0.0.1 = mydevserver.example.com into your /etc/hosts
  2. use a url shortener (eg. goo.gl) to create an alias to localhost

However, I believe that it is now possible to configure localhost in the Google api console.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
  • I am trying to run the quick start code of Real Time API of Google Drive given at following link: https://developers.google.com/drive/realtime/realtime-quickstart I think that I am getting error because I am using localhost as redirect URI and JS Origin. But some links on Stack Overflow says localhost can be used. http://stackoverflow.com/questions/11330919/correct-redirect-uri-for-google-api-and-oauth-2-0 Please tell me if you need any other detaail about my problem. – Rahul Oct 10 '13 at 17:30
  • 1
    You can't use localhost. You have 2 choices. (1) edit 127.0.0.1 = mydevserver.example.com into your /etc/hosts , (2) use a url shortener (eg. goo.gl) to create an alias to localhost – pinoyyid Oct 10 '13 at 17:53
  • 1
    Thanks a lot, I used 1st option and it worked for me. 2nd optiont did not work rather. Thank you very much. – Rahul Oct 10 '13 at 19:28
  • @Rahul can you tell me how you did it? As I can't do it, what I'm doing is going to c:\windows\system32\drivers\etc\hosts file and writing 127.0.0.1:4200 www.e.com – Muhammad Rehan Qadri Jun 18 '17 at 23:36
  • @MuhammadRehanQadri /etc/hosts in Android we are talking about. Not in windows. – Rahul Nov 12 '17 at 09:09
1

I had same problem with origin_mismatch.

From: Create a client ID section localhost should work and worked for me after small testing.

Origin in Google API i have:http://localhost
URL to address bar in browser:localhost

From the beginning this configuration not works, but after i tried write to address bar: 127.0.0.1->enter->origin_mismatch, it's correct and after again write localhost, now it's works.

Tested same behaviour in Firefox 39 and Google Chrome 37.0.2062.120 Ubuntu 12.04 (281580) (64-bit).

t0m
  • 3,004
  • 31
  • 53