我正在尝试通过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]**
我的client_secrets.json文件的内容(在第24行传递给程序)如下所示:
{"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。解决这个问题的任何帮助将不胜感激,因为我不知道它为什么会发生。
最佳答案
重定向_uris必须与开发者控制台的apps项目中设置的_uris相同。
关于python-2.7 - 无法为Youtube Analytics API配置OAuth2:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22109239/