Chat with us, powered by LiveChat

Change Twitter Profile Picture (Avatar) with Google Scripts

This Google Script updates the Twitter user’s profile image or avatar. Twitter asynchronously processes the uploaded file before updating the user’s profile image URL.

function oAuthConfig() {

  var oAuthConfig = UrlFetchApp.addOAuthService("twitter");
  oAuthConfig.setConsumerKey("PUT CONSUMER KEY HERE");
  oAuthConfig.setConsumerSecret("PUT CONSUMER SECRET HERE");
function setProfileImage() {
  // This is a picture that will be set as Twitter avatar
  var picture = UrlFetchApp.fetch("");
  var encodedImage = Utilities.base64Encode(picture.getContent());

  var options =
    "method": "post",
    "oAuthServiceName" : "twitter",
    "oAuthUseToken" : "always",
    "payload": { "image" : encodedImage, "skip_status": true}

  var request = UrlFetchApp.fetch("", options);