How to get logged in user avatar

371 views
Skip to first unread message

Ghanshyam

unread,
Mar 11, 2021, 1:48:44 PM3/11/21
to Google Apps Script Community
Hi Team,
I trying to get currently logged in user avatar but I don't see any function GAS provides for the same. Your input is appreciated
 
function loggedUser() {
  var user = Session.getActiveUser();
  var userName = user.getUsername();
 var email= user.getEmail()
}


Boris Baublys

unread,
Mar 12, 2021, 12:28:59 AM3/12/21
to Google Apps Script Community
Hi. This code works. Please provide more context to better understand your situation.

четверг, 11 марта 2021 г. в 21:48:44 UTC+3, gc.c...@gmail.com:

Faustino Rodriguez

unread,
Mar 12, 2021, 7:55:46 AM3/12/21
to Google Apps Script Community
In code below, userinfo would include the user's picture (if any) and other details from the user profile

    //  var user = Session.getEffectiveUser().getEmail(); // only to include scope https://www.googleapis.com/auth/userinfo.email
    var param = {
      method : "get",
      headers : {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
    };
    var response = UrlFetchApp.fetch(url, param);
    let code = response.getResponseCode();
    let content = response.getContentText();
    var userinfo = JSON.parse(content);


Reply all
Reply to author
Forward
0 new messages