You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to run the following script, however I get the error, Error authenticating: 'service_config'. I am unable to figure out why it isn't working. Thanks!
frompydrive2.authimportGoogleAuthfrompydrive2.driveimportGoogleDrive# Authenticate using service account credentialsgauth=GoogleAuth()
gauth.service_account_email='tiktokuploadacc@tiktikchannel.iam.gserviceaccount.com'gauth.service_account_file='./service_account.json'# Replace with the correct path to your service account JSON filegauth.scope= ['https://www.googleapis.com/auth/drive']
gauth.auth_method='service'try:
gauth.ServiceAuth()
exceptExceptionase:
print("Error authenticating:", e)
exit(1)
# Initialize GoogleDrive instancedrive=GoogleDrive(gauth)
# Example: Create a simple text file and upload itfolder_id='1BxjyaQ2eRo9CEYdN1CaeBQRIjzCblo57'# Replace with the ID of the folder where you want to upload the filefile_content="ABCDEFGHIJKLMNOPQRSTUVWXYZ"file_name="abc.txt"try:
file=drive.CreateFile({'title': file_name, 'parents': [{'id': folder_id}]})
file.SetContentString(file_content)
file.Upload()
print("File uploaded successfully:", file['title'])
exceptExceptionase:
print("Error uploading file:", e)
The text was updated successfully, but these errors were encountered:
I tried to run the following script, however I get the error,
Error authenticating: 'service_config'
. I am unable to figure out why it isn't working. Thanks!The text was updated successfully, but these errors were encountered: