Elijas / auto-youtube-subscription-playlist-2

Script automatically adds videos to playlists from Youtube channels and/or subscriptions (Youtube Collections alternative).
MIT License
246 stars 54 forks source link

I can't authorize sending emails #121

Open kurokirasama opened 1 year ago

kurokirasama commented 1 year ago

Hey, I tried adding this:

function sendLog(newvideos){
  var recipient = Session.getActiveUser().getEmail();
  var subject = 'YT2Discord Log: ' + newvideos + 'new videos.';
  var body = Logger.getLog();
  MailApp.sendEmail(recipient, subject, body);  
}

When running a script, I'm usually asked for permissions, but here I'm not, and therefore getting this error message:

Exception: You do not have permission to call Session.getActiveUser. Required permissions: https://www.googleapis.com/auth/userinfo.email
sendLog @ sendLog.gs:2
updatePlaylists @ Code.gs:200
victorjzsun commented 1 year ago

Sometimes google apps script is just finicky with the permissions dialog, have you tried running it again after some time?

victorjzsun commented 1 year ago

You might also need to add the scope to the manifest.

FYI, here's a way to force the authorize permissions dialog: https://stackoverflow.com/a/52276300, run this and then call any other function.