porjo/youtubeuploader

Error making YouTube API call - Token has been expired or revoked

ChristianErdtmann opened this issue · 2 comments

Hey i have done all correct upload was working.
Then i tried to upload again something some days later now i get the Message:

2022/09/17 14:28:34 Error making YouTube API call: Post "https://youtube.googleapis.com/upload/youtube/v3/videos?alt=json&notifySubscribers=true&part=snippet&part=status&part=recordingDetails&prettyPrint=false&uploadType=resumable": oauth2: cannot fetch token: 400 Bad Request
Response: {
"error": "invalid_grant",
"error_description": "Token has been expired or revoked."
}
exit status 1

I don't know why i get this error can you explain how to solve it and in best case how to avoid it too please.

I already tried to delete the request.token file but that doesnt work i get still the same error.
After deleting the token i additional moved the oAuth Screen form Test to Production Mode and run again.
Still the same error. What i do wrong?

After that i have deleted the client-secrets, created new client-secrets renamed it and moved it to the projectfolder.
But now i get the message:
2022/09/17 14:53:54 Error making YouTube API call: Post "https://youtube.googleapis.com/upload/youtube/v3/videos?alt=json&notifySubscribers=true&part=snippet&part=status&part=recordingDetails&prettyPrint=false&uploadType=resumable": oauth2: cannot fetch token: 401 Unauthorized
Response: {
"error": "deleted_client",
"error_description": "The OAuth client was deleted."
}
exit status 1

So why the software still know my Token?
I have deleted the request.token and i have replaced the client-secrets but it still want to use the old token. Why? How i solve it and avoid it in the future?

I have now tried to do it on a other machine, because of this i installed all on a fresh pc. I removed the client_secrets.json and the request.token file. I genereated a new client_secrents.json with an OAuth Consens Screen wich is set to production.

But it still dont work on the other machine.
Still got error:
2022/09/20 16:38:23 Error making YouTube API call: Post "https://youtube.googleapis.com/upload/youtube/v3/videos?alt=json&notifySubscribers=true&part=snippet&part=status&part=recordingDetails&prettyPrint=false&uploadType=resumable": oauth2: cannot fetch token: 400 Bad Request
Response: {
"error": "invalid_grant",
"error_description": "Token has been expired or revoked."
}
exit status 1

pleasse help.

I found now the Problem, and got another.
I have 2 locations where the youtubeuploader is saved.

  1. C:\Programm Files\Go\src.....
  2. And at the directory where i saved the project folder for each specific YTchannel.

I need to remove the client_secrets and request.token in both folders.
If i start the youtubeuploader over go run .... at both places it generate at both places the request.token

But now i have the Problem i want to use it to upload for 2 channels.
I cant do this because alltimes at C:\Programm Files\Go\src\ is saved the token.reques for just 1 channel, because of this i cant upload to the 2. channel without deleting files and generate new. But for that i need alltimes to manual approve it at the first start. Thats a big problem for me.

Any Idea?

How can i avoid that? In best cause i would like to remove it from C:\Programm Files\Go\src\youtubeuploader and just have it at different places for different youtubechannels with different requst tokens

porjo commented

I'm not sure if I understand your problem correctly, but the way it should work is:

  • youtubeuploader will read files from current directory by default unless you specify a location with -cache and -secrets flag
  • use a single client_secrets.json file (regardless of which Youtube account you upload to)
  • use multiple request.token files - one for each Youtube account you upload to