James Cole
James Cole

Reputation: 51

I'm trying to access Google Drive through the CLI, but keep getting "Not authorized to request the scopes"

I used to run a script that would back up various files and put them in my GDrive. Simple bash, really. By "putting them in GDrive" I mean it would simple move the files to ~/Google Drive/ which would be picked up by my laptop.

I'm trying to build a similar app that will upload certain files to my Google Drive. It should be started by me, save the auth details and then start uploading. This must also run from the command line. However, there is no Google Drive client that will pick up the files. I must upload the files myself.

Currently, I'm having trouble with the OAuth2 procedure. I've set up a project on cloud.google.com, I have the keys, the library ready and the scopes set up, but Google keeps refusing my request. I've enabled both the Drive API and the Drive SDK.

The error I'm getting is:

{
  "error" : "invalid_scope",
  "error_description" : "Not authorized to request the scopes: [https://www.googleapis.com/auth/drive]",
  "error_uri" : "http://code.google.com/apis/accounts/docs/OAuth2.html"
}

No matter what I try, I cant get this scope to work. Other scopes work fine. Trying to find what could cause this is impossible, the Google searches I've tried are muddled.

These are the scopes I'm requesting:

https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile

What am I missing?

Upvotes: 1

Views: 1108

Answers (2)

Dimitar
Dimitar

Reputation: 1928

Are you sure you enable the API's for Google Drive API, Drive SDK, Google+? You have to do this in order to use those scopes from Google Developer Console

Upvotes: 0

James Cole
James Cole

Reputation: 51

I've managed to get access using the following scope instead of https://www.googleapis.com/auth/drive:

https://docs.google.com/feeds

From the manual:

Full, permissive scope to access all of a user's files. Request this scope only when it is strictly necessary. Tokens with scope https://docs.google.com/feeds are accepted and treated the same as tokens with scope https://www.googleapis.com/auth/drive.

I tried it, and it worked.

Upvotes: 3

Related Questions