I'm using google apps scripts to try and alter a YouTube title, which seems simple and the code works (for the main account), just not for brand account videos. The difficulty I'm finding is simple: When I run the script, it asks me to authorize the script, which makes sense, so I go through and authorize with the brand account, and it says "Error: You need to authorize with a google account" <- not the exact quote but it's the gist, so I rerun the script and authorize with my main email account, the account that runs the brand account.
And it doesn't verify, so I've been trouble shooting for around 5 hours today trying to fix this code I've added it to a google cloud project, added a bunch of scopes (i don't know which ones tbh, just anything that people or ai suggested, which btw does work the code works on my main account), and I created all the things I needed to the cloud project that being a Oauth 2.0 client ID, a consent screen, then I've also tried re authorizing with Oauth 2.0 playground.
Nothing has worked, for some reason I can't get the code to change a video's title that's been uploaded under the brand account, again it does work for the main account.
Everything I've seen online has been, to be completely honest here, useless.
Here's the code:
function updateTitle() { var videoID = 'jTY9QAzCXBc'; //works with 6yzY_E6454w because it's owned by main. var part = 'snippet,statistics'; var params = {'id': videoID}; var response = YouTube.Videos.list(part, params); var video = response.items[0]; var videoViewsCount = video.statistics.viewCount; var videoTitle = 'This Video Has '+ videoViewsCount +' Views'; video.snippet.title = videoTitle; try { YouTube.Videos.update(video, part); // 50 units sets the title } catch (e) { console.error(e); }}
It's very simple, and just confirmed again it does work for the main account.
Things I've tried:
- Authorizing and Reauthorizing with 2.0 playground
- Integrating it with a fully setup google cloud project
- Adding all necessary APIs (YouTube Data API in this case)
- Adding an authorize function where it will rerun the authorize so I can authorize both (none of that worked)
- Debugging, rerunning, and reauthorizing 6 different times with 6 different processes
Any help is massively appreciated and it would be a massive aid in trying to create a thread that actually fixes this definitively. Any work around to this yet?
I was following this and did try the suggestion but I'm new to this and need help cause this is the last thing I tried: YouTube APIs - Access mutiple youtube channels (Brand Accounts) using Google Admin account