Google Drive REST API DriveQuickstart错误400:redirect_uri_mismatch JAVA [英] Google Drive REST API DriveQuickstart Error 400: redirect_uri_mismatch JAVA

查看:83
本文介绍了Google Drive REST API DriveQuickstart错误400:redirect_uri_mismatch JAVA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成了此处列出的所有步骤: https://developers.google.com/drive/v2/web/quickstart/java 现在,当我运行我的项目时,它给了我400错误,在Chrome上重定向网址不匹配.

I've gone through all of the steps listed here: https://developers.google.com/drive/v2/web/quickstart/java and now when I run my project, it gives me a 400 error, redirect url mismatch on Chrome.

我已尝试从此处按照以下多个说明进行操作: Google OAuth 2授权-错误:redirect_uri_mismatch ,但是我遇到两个关键问题:当我在开发人员控制台中注册URI时,我没有将重定向URI放入其中的字段,并且每次我的重定向URI都不相同.我能说什么.

I've tried following multiple instructions from here: Google OAuth 2 authorization - Error: redirect_uri_mismatch but I am having two key problems: When I go to register the URI in my developers console, I have no field to put the redirect URI's in, and my redirect URI is different every time, from what I can tell.

如何添加重定向URI,并且每当我运行该程序时,每次重定向URI似乎都是不同的.

How can I add a redirect URI, and also whenever I run the program, the redirect URI seems to be different every time.

从控制台获取(运行1和运行2):

Taken from the console ( run 1, and run 2):

redirect_uri=http://localhost:62210/
redirect_uri=http://localhost:62349/

所以我不知道如何考虑动态重定向URI.

So I have no idea how to account for dynamic redirect URI's.

我的代码完全与quickstart/java链接匹配

My code matches the quickstart/java link exactly

这是控制台输出:

Feb 08, 2016 7:42:38 PM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for everybody: C:\Users\Speedy Octopus\.credentials\drive-java-quickstart
Feb 08, 2016 7:42:38 PM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for owner: C:\Users\Speedy Octopus\.credentials\drive-java-quickstart
2016-02-08 19:42:38.378:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
2016-02-08 19:42:38.378:INFO::jetty-6.1.26
2016-02-08 19:42:38.388:INFO::Started SocketConnector@localhost:62210
Please open the following address in your browser:
  https://accounts.google.com/o/oauth2/auth?client_id=20967686237-compute@developer.gserviceaccount.com&redirect_uri=http://localhost:62210/Callback&response_type=code&scope=https://www.googleapis.com/auth/analytics.readonly
Attempting to open that address in the default browser now...

推荐答案

前几天,我遇到了完全相同的问题,基本上google不太清楚他们是否需要返回的地址以及回调uri.在已注册项目的开发控制台的凭据",授权重定向URI"下,您需要添加回调uri,在本例中为 http://localhost:62210/Callback .没有该Google,就无法确定它会返回正确的uri.

I ran into the exact same problem the other day, basically google is not very clear about the fact that they need both the address that they will be returning to and the callback uri. In your development console where you have registered your project, under 'credentials', 'Authorized redirect URIs' you need to add your callback uri, in this case http://localhost:62210/Callback. Without that google cannot be sure it is returning to the right uri.

这篇关于Google Drive REST API DriveQuickstart错误400:redirect_uri_mismatch JAVA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆