【问题标题】:Google API OAuth for Drive API is not working. Getting Error: origin_mismatchDrive API 的 Google API OAuth 不工作。出现错误:origin_mismatch
【发布时间】:2013-10-17 18:03:49
【问题描述】:

我正在尝试运行 Google Drive 的 Real Time API 的快速启动代码。 我相信我做的一切都是正确的。但我得到了

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

【问题讨论】:

    标签: oauth google-drive-api google-oauth google-drive-realtime-api


    【解决方案1】:

    您没有详细说明您的应用程序架构,所以我只能建议一个一般性的答案。 OAuth 限制哪些 URL 可以引用它。允许的 URL 列表在 API 控制台中配置为 https://code.google.com/apis/console。 URL 非常繁琐,因此请确保输入的内容与地址栏中显示的内容完全相同。

    截至 2013 年 10 月,您不能使用 localhost。您有 2 个选择。

    1. 将 127.0.0.1 = mydevserver.example.com 编辑到您的 /etc/hosts 中
    2. 使用 url 缩短器(例如 goo.gl)创建 localhost 的别名

    不过,我相信现在可以在 谷歌 API 控制台。

    【讨论】:

    • 我正在尝试运行以下链接中提供的 Google Drive 实时 API 的快速启动代码:developers.google.com/drive/realtime/realtime-quickstart 我认为我遇到了错误,因为我使用 localhost 作为重定向 URI 和 JS Origin .但是 Stack Overflow 上的一些链接说可以使用 localhost。 stackoverflow.com/questions/11330919/…如果您需要有关我的问题的任何其他详细信息,请告诉我。
    • 你不能使用本地主机。你有2个选择。 (1) 将 127.0.0.1 = mydevserver.example.com 编辑到您的 /etc/hosts 中,(2) 使用 url 缩短器(例如 goo.gl)创建 localhost 的别名
    • 非常感谢,我使用了第一个选项,它对我有用。第二个选项不起作用。非常感谢。
    • @Rahul 你能告诉我你是怎么做到的吗?因为我做不到,所以我正在做的是 c:\windows\system32\drivers\etc\hosts 文件并写入 127.0.0.1:4200 www.e.com
    • @MuhammadRehanQadri /etc/hosts 在我们正在谈论的 Android 中。不在 Windows 中。
    【解决方案2】:

    我对 origin_mismatch 有同样的问题。

    来自:Create a client ID section localhost 经过小测试后应该可以为我工作。

    我有 Google API 的来源:http://localhost
    浏览器地址栏的 URL:localhost

    从一开始这个配置不起作用,但是在我尝试写入地址栏后:127.0.0.1->enter->origin_mismatch,它是正确的,然后再次写入localhost,现在它可以工作了。

    在 Firefox 39 和 Google Chrome 37.0.2062.120 Ubuntu 12.04 (281580)(64 位)中测试了相同的行为。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多