Change Twitter Profile Picture (Avatar) with Google Scripts

Published in: Google Apps Script - Twitter

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);
Published in: Google Apps Script - Twitter

Looking for something? Find here!

Meet the Author

Web Geek, Google Developer Expert
Amit Agarwal

Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India. He is the developer of Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory

Get in touch