【问题标题】:Difficulty configuring OAuth2 for Youtube Analytics API:为 Youtube Analytics API 配置 OAuth2 的困难:
【发布时间】:2014-04-02 06:52:07
【问题描述】:

我正在尝试通过 python 使用 Youtube Analytics API。我从 Google 开发者网站下载了示例 python 代码。这是链接:

https://developers.google.com/youtube/analytics/v1/code_samples/python

每当我运行它时,我的浏览器都会打开一个包含以下错误消息的页面:

**Error: redirect_uri_mismatch The redirect URI in the request: [http://localhost:8080/] did not match a registered redirect URI**

我在 Google Cloud Console 上的应用程序设置了以下重定向 uri 和 javascript 来源:

**Redirect URIs     
[http://localhost:8080/oauth2callback]
Javascript Origins  
[http://localhost:8080]**

我在第 24 行传递给程序的 client_secrets.json 文件的内容如下:

{"web":{"auth_uri":"[https://accounts.google.com/o/oauth2]/auth","client_secret":"KNLERUsUrOsOiJTzyaSWN2JG","token_uri":"[https://accounts.google.com/o/oauth2/token]","client_email":"409435120404-k62menuelac66nbl9ic82uqakbd4nhrh@developer.gserviceaccount.com","redirect_uris":["[http://localhost:8080/oauth2callback]"],"client_x509_cert_url":"[https://www.googleapis.com/robot/v1/metadata/x509/409435120404-k62menuelac66nbl9ic82uqakbd4nhrh@developer.gserviceaccount.com]","client_id":"409435120404-k62menuelac66nbl9ic82uqakbd4nhrh.apps.googleusercontent.com","auth_provider_x509_cert_url":"[https://www.googleapis.com/oauth2/v1/certs]","javascript_origins":["[http://localhost:8080]"]}}

我正在运行 Ubuntu 13.10。任何解决此问题的帮助将不胜感激,因为我不知道为什么会发生这种情况。

【问题讨论】:

    标签: python-2.7 youtube google-analytics


    【解决方案1】:

    重定向 _uris 需要与您在开发者控制台的应用程序项目中设置的相同。

    【讨论】:

    • DalmTo,感谢您的回复;但是,我已经将 redirect_uris 设置为与我提供的授权相同。您可以看到我的 json 文件中的地址匹配。其实那个json文件是google云控制台根据我设置的redirect_uris生成的。
    猜你喜欢
    • 1970-01-01
    • 2019-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-10
    • 2014-10-24
    • 1970-01-01
    相关资源
    最近更新 更多