0

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.

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.

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

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

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

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

My code matches the quickstart/java link exactly

Here is the console output:

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...
Community
  • 1
  • 1
Todd Leach
  • 35
  • 1
  • 8

1 Answers1

0

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.

Dallen
  • 287
  • 5
  • 15
  • When creating the new Credential, what did you select in terms of type of project? I chose "Other" and there is no place for me to put redirect URIs. the other options were Web Application, android, chrome app... etc. If you didnt chose Other, is there a way to change my selection or do I have to create a new project? – Todd Leach Feb 09 '16 at 01:58
  • The application I was developing was a website so I could simply use a web callback, however if you are going to write a local application you should be able to select other and the code you need to validate the user will be sent supplied to the user so they can copy it into your application. Other should work, however if you would like to change your credential type, you do need to make a new set of them under 'new credentials', 'oauth client ID'. I dont think you should supply a redirect_uri for a project of type other. – Dallen Feb 09 '16 at 02:24