Open godspeedyou opened 4 years ago
I removed that second step, as you're right, it is default now.
Regarding the error, according to documentation, the Forbidden
error occurs when either The playlist already contains the maximum allowed number of items
or The request is not properly authorized to insert the specified playlist item
. Can you please check both of these?
The new (target) playlist was empty. How do I check the proper authorization?
As in make sure that you own the playlist (there might be some conflict if you're trying to add to another user's playlist). Make sure that the playlist ID you put into the first column of the sheet does indeed point to the right playlist by going to the link https://www.youtube.com/playlist?list=[yourplaylistIDhere]
replacing [yourplaylistIDhere]
with the actual ID.
I've also pushed a new change to the sheets script (to log more details on API fail errors) so if you could update your script in the script editor and post the result, that'd be great.
Thanks for the administration.
I copied the sheet freshly from the github starting page, granted access and the script ran. It failed with the following error.
Tue Nov 05 22:46:43 EET 2019 | Acquired 1 videos |
---|---|
Tue Nov 05 22:46:43 EET 2019 | Couldn't update playlist with video (XB8sV_DMFDE), ERROR: Message: [API call to youtube.playlistItems.insert failed with error: Forbidden] Details: {"message":"Forbidden","code":403,"errors":[{"domain":"youtube.playlistItem","reason":"playlistItemsNotAccessible","message":"Forbidden"}]} |
Tue Nov 05 22:46:43 EET 2019 | Added 0 videos to playlist. Error for 1 videos. |
See the attachments for my setup.
One thing I'm noting is that the account you're using for the sheet is not the same as the YT account with the playlist (Purple A vs Dog profile icon). Please use the same account as the one that owns the playlist since there might be some complications with using a different account to add videos
That may be the issue. However, the dog profile is my brand account (under the A account) which I've been using for several years and I'm kind of dependent on it. I'd like to avoid a migration to the A account, since I've been using the dog account for many years (playlists, subscriptions, comments and so on are connected to it). I'm going to verify that this is the problem and think about migrating. On the other hand I'd appreciate it very much, if you could find a way to support brand accounts.
That's interesting, and it seems like the reason why it's giving a forbidden error. Brand accounts are completely separate from the personal accounts associated with them, so permissions are not transferable.
According to this post, you can try logging into Google Drive/Sheets using that brand account and run the script under that account instead of the "A" account. This will be a temporary solution until I can figure out exactly how permissions work between playlists and if I can find a better solution than switching accounts. I'll see what I can do.
I have the feeling the StackOverflow answer is outdated. I can't choose Google Drive as an product at https://myaccount.google.com when signed in as my brand. And I haven't found a way yet to log in with the mentioned @pages.plusgoogle.com address to Google Drive directly. It tells me I have the wrong password, when I'm using the A account's password. I contacted the StackOverflow user for advice.
I have the feeling the StackOverflow answer is outdated. I can't choose Google Drive as an product at https://myaccount.google.com when signed in as my brand. And I haven't found a way yet to log in with the mentioned @pages.plusgoogle.com address to Google Drive directly. It tells me I have the wrong password, when I'm using the A account's password. I contacted the StackOverflow user for advice.
I can't find a way to login to google drive with the brand account. I assume google scrapped this feature together with google plus.
Not sure if this is helpful, but it turned out to be really easy to just move my YouTube brand account to a personal Google. Then the script worked great (minus hitting my quota). Thanks for making this tool.
I tried the method of generating a refresh token as mentioned in this Stackoverflow post about YouTube APIs, but I am a novice with regards to scripting, working with APIs, etc.
How would I incorporate a generated refresh token into this script to make it work for a YouTube brand account?
That would be pretty difficult and hard to automate without creating a whole new standalone app. I was able to generate a token for a brand account and then use that token to request data from an API, but I cannot do so using a google app such as Google Apps Script, since such an app restricts the caller of the script to be the main account and not a brand account. Basically, since google doesn't allow anyone to sign into a script with a brand account, we'd need to create a whole sign-in architecture that allows for brand accounts.
For anyone who still wants to dive deeper into this issue, here's the process for creating a brand account token:
Desktop App
oauth client id/secret to a project as described herehttps://accounts.google.com/o/oauth2/v2/auth
as described here, passing the client id generated above and setting the redirect_uri
to urn:ietf:wg:oauth:2.0:oob
for manual copy and paste of auth code. Make sure to provide the API scopes you need and set request_type
to code
This can be done with a formatted request on a browser, an app like Postman won't work because the sign-in dialog box is returnedhttps://oauth2.googleapis.com/token
as described here, passing in the auth code you got from above, as well as client id/secret, and specifying grant_type=authorization_code
. Again, set redirect_uri
to urn:ietf:wg:oauth:2.0:oob
to get the token manually.In terms of how to use this token, at least to test if it works, just send a request to any Google API with an auth header with your token and it should work. To run an Apps Script, the only way I can see is by using something like clasp to run the script remotely using a certain set of credentials (your generated token), but I have yet to see if this works.
Long story short, if we wanted to do something about it, we might as well be Google employees
Hi, here is the solution https://stackoverflow.com/a/64902884/7484338
I followed the instructions, but couldn't execute the second step completely:
I can't find any Google Developers Console in the
Resources / Advanced Google Services
dialog. According to https://developers.google.com/apps-script/guides/services/advanced#enabling_advanced_services that option is available fora standard GCP project (or an older default GCP project that was created prior to April 8, 2019)
.Nonetheless I tried to "Update Playlists" in the sheet document and this is the error message in the debug sheet:
Sorry for the German log message. It means something like
Couldn't update playlist with video (5Aq7jyS8AAU), ERROR: The following error occured at api call "youtube.playlistItems.insert": Forbidden