I am simply trying to create a new folder on google drive using the Google Drive API
.
I have created a Service Account
as well as a OAuth 2.0 Client IDs
(and have downloaded their respective client secret .json
files) for a project in which the Drive API has been enabled.
However, I am still encountering endless problems. The template example below has not worked for me (nor have any other solutions to people encountering the same problem).
file_metadata = {
'name': 'Invoices',
'mimeType': 'application/vnd.google-apps.folder'
}
file = drive_service.files().create(body=file_metadata,
fields='id').execute()
print 'Folder ID: %s' % file.get('id')
If I am using:
SCOPE = ['https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name(CLIENT_SECRET_FILE, SCOPE)
then plugging in the .json
downloaded from the Service Account for CLIENT_SECRET_FILE
, I get the error Client secrets must be for a web or installed app
If I instead try to authenticate CLIENT_SECRET_FILE
with a key json file generated via OAuth2 credentials I get and Authorization Error
Error 400: redirect_uri_mismatch
The redirect URI in the request, http://localhost:8080/, does not match the ones authorized for the OAuth client...
I have also created an API Key
for the project. Is there an easier way to achieve this by using the API Key, as opposed to the .json files?
Any help would be much appreciated.