Google Drive: Custom client ID and OAuth2 issues


#1

Hello.

I’ve got my custom client ID and secret for Google Drive following the steps at Drive’s page on rclone site.

Afterwards, I added both client ID and secret to my existing remote and Google greeted me with a 401 unauthorized client error, which I tried to fix by getting a new token with rclone’s auto procedure.

I have not been able to do this. The web page that opens after agreeing to autoconfig is not the Google login page but an error page saying this:

Error: redirect_uri_mismatch
The redirect URI in the request, http: //127.0.0.1:53682/, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs, visit: https://console.developers.google.com/apis/credentials/oauthclient/myclientID

Then I tried to add the domains “127.0.0.1” and “localhost”, with and without port and protocol in 2 different places in Google APIs site, but I’ve been unsuccessful in adding the domains and performing the OAuth2 authentication.

Things haven’t been better by searching this forum and googling the issue, so I’m requesting a bit of help.

Thank you in advance.


#2

How are you setting it up? Are you directly on the machine where you have rclone running or are you connecting to a server through for example SSH?


#3

It seems to be complaining about the Redirect URL for some reason. I don’t know how you set that (you don’t need to normally).

If I download my credentials they look like this - note the localhost RedirectURL.

{
  "installed": {
    "client_id": "XXX.apps.googleusercontent.com",
    "project_id": "XXX",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_secret": "XXX",
    "redirect_uris": [
      "urn:ietf:wg:oauth:2.0:oob",
      "http://localhost"
    ]
  }
}

#4

Ok. I got it working.

I figured it out when I compared my json credentials file with the one ncw pasted above.

It turns out that I generated credentials for a web app. This time I’ve generated credentials for “other” and it authorized smoothly the first time I tried.

Thank you very much.


#5

Great :smile: Glad you got it working!