Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Constant 403s #392

Open
hamptonmoore opened this issue Jun 22, 2018 · 21 comments
Open

Constant 403s #392

hamptonmoore opened this issue Jun 22, 2018 · 21 comments
Labels
bug Something isn't working as it's supposed to investigating Searching underlying causes and possible solutions to the problem workaround available Bypassing this issue is possible until fix is introduced

Comments

@hamptonmoore
Copy link

Failed to get file: googleapi: Error 403: Rate Limit Exceeded, rateLimitExceeded
Pretty much anytime I run gdrive download I end up with this

@jvfiel
Copy link

jvfiel commented Aug 5, 2018

Same issue, any ideas?

@hamptonmoore
Copy link
Author

I just switched to rclone and it fixed everything :P

@LINKIWI
Copy link

LINKIWI commented Sep 20, 2018

The author hardcoded his or her own client ID and secret directly in the source:

const ClientId = "367116221053-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleusercontent.com"

Which means, if you're using the compiled binary published in this repository's releases page, you are effectively sharing the same quota with everyone else who downloaded a binary. Google APIs make a distinction between rate limit errors and user rate limit errors. In this case the error is most likely "not your fault" but rather a symptom of a lot of people using gdrive at the same time.

You can enable the Drive API in your own account, create a set of credentials, replace it in the source above, and recompile. Then the API-level quota will be consumed by only yourself.

@BaconCatBug
Copy link

This is weird because I have the same problem when I run the command via crontab, but if I run it manually it works.

@alpercalisir
Copy link

alpercalisir commented Dec 4, 2018

@LINKIWI I did the same things as you instructed. However, after I changed my ClientID and ClientSecret I got this error:

Failed to create directory: Post https://www.googleapis.com/drive/v3/files?alt=json: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "invalid_client",
  "error_description": "Unauthorized"
}

Note that before compilation I moved build-all.sh,print_usage_markdown.sh, and upload.sh to the gdrive folder where I can succesfully compile with the old ClientID and ClientSecret.

@internalkernel
Copy link

Seeing this issue also... Even seems to happen for simple operations like creating a folder. Also noticing that this bug has been lingering since 2017... I guess Rclone is the answer... Thanks anyways.

@smx06
Copy link

smx06 commented Jan 28, 2019

@gdrive + @LINKIWI:

"Drive API in your own account, create a set of credentials"
Which kind of app need I create?

  1. web app creation gives oauth2 client ID and secret (like in handlers_drive.go) but when replacing with em - "gdrive about" says web app can't access - "you need a native app"
  2. Android app creation gives oauth2 client ID but doesn't give secret!
  3. Other app type - doesn't work

So which is correct? or am I missing something?

@smx06
Copy link

smx06 commented Jan 28, 2019

NB: @gdrive + @LINKIWI:
2) if creating Android app and placing just client-ID (no valid secret)
it says
Enter verification code: 4/4ABWn1qjGi5pbgxk9wWpkWGnl66GKkcwg0a47_RW22hnyUXlSlmfP9s
Failed getting oauth client: Failed to exchange auth code for token: oauth2: cannot fetch token: 401 Unauthorized
Response: {
"error": "invalid_client",
"error_description": "Unauthorized"
}

@LINKIWI
Copy link

LINKIWI commented Jan 28, 2019

What do you mean by "doesn't work"?

@smx06
Copy link

smx06 commented Jan 29, 2019

Yesterday "other" app type produced google error on creating.
Today works fine and new gdrive works! Thank you!

@smx06
Copy link

smx06 commented Jan 29, 2019

pps To speed things up binary editing can be used (to replace Id and secret in the built executable)

@scrumbee
Copy link

scrumbee commented Jan 30, 2019

Would anyone be abel to help me out either explain step by step how edit the binary or how to compile a version for me that would work with ubuntu 16.04. im willing to even pay a little for help if your willing talk me trough and help privately. Like the amount of 403 errors these days just to point of this tool not being useful anymore. But yea at end of the day best solution would be to move this portion to a config file so everyone change change it themselves.

@smx06
Copy link

smx06 commented Jan 31, 2019

You can build from sources like all do. About editing just use any binary editor (like ghex2, hexedit, etc.)
Find string
1qsNodXNaWq1mQuBjUjmvhoO
and replace it with your Secret string
find string
367116221053-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleusercontent.com
and replace it with your Google clientId

@mbenlioglu mbenlioglu added bug Something isn't working as it's supposed to investigating Searching underlying causes and possible solutions to the problem workaround available Bypassing this issue is possible until fix is introduced labels Mar 11, 2019
@mbenlioglu
Copy link
Contributor

Available workaround described in #426. Possible solutions will be investigated.

@grandeto
Copy link

Rebuild the repo with your own credentials.
Tested on Ubuntu 16.04

**use sudo if needed on your enviroment

apt-get install git
apt-get update
apt install software-properties-common
add-apt-repository ppa:git-core/ppa # apt update; apt install git
// Install go
wget https://dl.google.com/go/go1.12.linux-amd64.tar.gz
mv go1.12.linux-amd64.tar.gz /usr/local/
cd /usr/local
tar -zxvf go1.12.linux-amd64.tar.gz
cd ~
nano .profile
// Add these global variables as follow at the end of the file:
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
// Update current shell session:
source ~/.profile
// Check go version
go version
// Login to google developers and create a new project. Give it name for instance Gdrive-my-project
https://console.developers.google.com/apis/dashboard
// Go to google drive api and enable it. Then click on Credentials
https://console.developers.google.com/apis/library/drive.googleapis.com
// From dropdown choose Other UI and check User data
// Then click on "What credentials do I need?"
// Give again same name Gdrive-my-project and save
// If old gdrive installation exists:
cd ~
rm -r gdrive
rm -r .gdrive
rm /usr/local/bin/gdrive
// Get the repo
go get github.com/gdrive-org/gdrive
cd go/src/github.com/gdrive-org/gdrive/
nano handlers_drive.go
// On line 17 and 18 change the credentials (ClientId and ClientSecret) with those created in google drive api
// Compile the executable by run ‘go build’ in go/src/github.com/gdrive-org/gdrive/
go build
install gdrive /usr/local/bin/gdrive
install gdrive ~/go/bin/gdrive
// Run some gdrive command to setup the gdrive permissions
gdrive about

@southbot
Copy link

southbot commented Apr 6, 2019

I rebuilt gdrive and still got the 403 error.
One of the possible causes is that your machines network speed is very fast and exceeds the maximum speed allowed for uploads. I wrote a bash script that fixed it for me. Note that I first create a list of file names that I wish to upload using ls *.jpg >list.txt. The are other ways of doing it without a list but by using a list you can pick up where you have left off by deleting the names that have already been uploaded, if the upload does not succeed.

@southbot
Copy link

southbot commented Apr 6, 2019

#!/bin/bash
FILES="list.txt"
while read f ; do
MAXTRIES=4
COUNT=0
BACKOFF=1
while [ $COUNT -lt $MAXTRIES ];do
gdrive upload --parent "put your google drive directory id here without quotes" $f
if [ $? -eq 0 ];then
break
else
let COUNT=COUNT+1
let BACKOFF=BACKOFF*2
echo "Attempt $COUNT failed retrying after $BACKOFF seconds"
sleep $BACKOFF
fi
done
if [ $COUNT -ge $MAXTRIES ];then
echo "Upload failed at $f"
break
fi
done < $FILES

@southbot
Copy link

southbot commented Apr 9, 2019

Use this if your list contains directories...

#!/bin/bash
FILES="list.txt"
OLD_DIR=""
while read f ; do
MAXTRIES=4
COUNT=0

BACKOFF=1 
DIR=$(dirname "${f}")
if [ "$DIR" != "$OLD_DIR" ];then
	DCOUNT=0
	while [ $DCOUNT -lt $MAXTRIES ];do
		abc=$(gdrive mkdir $DIR)
		echo abc = $abc
		outt=$(awk -F " " '{print $2}' <<< "$abc")	
		chk=$(awk -F " " '{print $1}' <<< "$abc")
		if [ "$chk" == "Directory" ];then
			break
		else
			let DCOUNT=DCOUNT+1
			sleep 4
		fi
	done
	if [ $DCOUNT -ge $MAXTRIES ];then
		echo "Upload failed at creating $DIR directory" 
		break
	fi		
	OLD_DIR=$DIR
	echo Directory = $DIR
	echo outt = $outt
fi	
while [ $COUNT -lt $MAXTRIES ];do 
	gdrive upload --parent $outt $f
	if [ $? -eq 0 ];then
		break
	else
		let COUNT=COUNT+1 
		let BACKOFF=BACKOFF*2 
		echo "Attempt $COUNT failed retrying after $BACKOFF seconds" 
		sleep $BACKOFF 
	fi 
done
if [ $COUNT -ge $MAXTRIES ];then
	echo "Upload failed at $f" 
	break
fi

done < $FILES

@pablodc00
Copy link

@grandeto
thanks for the walkthrough,
I have not experience with go language and I'm geting this error when I try to run
go get github.com/gdrive-org/gdrive
package context: unrecognized import path "context" (import path does not begin with hostname)
any clue?
thanks in advance!

@grandeto
Copy link

grandeto commented Dec 3, 2019

@pablodc00 It seems to be an old go version or go env variable not set correctly issue. checkout here:
golang/dep#1985 or google it

@SalimF
Copy link

SalimF commented Dec 5, 2019

// Login to google developers and create a new project. Give it name for instance Gdrive-my-project
https://console.developers.google.com/apis/dashboard
// Go to google drive api and enable it. Then click on Credentials
https://console.developers.google.com/apis/library/drive.googleapis.com
// From dropdown choose Other UI and check User data

For people who cant find these instruction easy this is screen shot of how it will looks like .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working as it's supposed to investigating Searching underlying causes and possible solutions to the problem workaround available Bypassing this issue is possible until fix is introduced
Projects
None yet
Development

No branches or pull requests