title: Update user photo in G Suite
body: <p>I am trying to update the user photo for a G Suite user using the following code:</p>
  
  <pre><code>require 'google/apis/admin_directory_v1'
  require 'googleauth'
  require 'googleauth/stores/file_token_store'
  
  require 'fileutils'
  
  OOB_URI = 'urn:ietf:wg:oauth:2.0:oob'
  CLIENT_SECRETS_PATH = 'client_secrets.json'
  CREDENTIALS_PATH = File.join(Dir.home, '.credentials',
                               "admin-directory_v1-ruby-quickstart.yaml")
  SCOPE = "https://www.googleapis.com/auth/admin.directory.user"    
  
  def authorize
    FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))
  
    client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)
    token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)
    authorizer = Google::Auth::UserAuthorizer.new(
      client_id, SCOPE, token_store)
    user_id = 'default'
    credentials = authorizer.get_credentials(user_id)
    if credentials.nil?
      url = authorizer.get_authorization_url(
        base_url: OOB_URI)
      puts "Open the following URL in the browser and enter the " +
           "resulting code after authorization"
      puts url
      code = gets
      credentials = authorizer.get_and_store_credentials_from_code(
        user_id: user_id, code: code, base_url: OOB_URI)
    end
    credentials
  end
  
  # Initialize the API
  service = Google::Apis::AdminDirectoryV1::DirectoryService.new
  service.authorization = authorize
  
  require "base64"    
  pic = Base64.encode64(File.read('profilepic.png')).tr("+/", "-_")
  
  photo = Google::Apis::AdminDirectoryV1::UserPhoto.new
  photo.photo_data = pic
  
  service.update_user_photo("user@domain.com", photo)
  </code></pre>
  
  <p>But then I'm getting the error <code>"invalid: Invalid Input: photoData (Google::Apis::ClientError)"</code>. I am starting to suspect that this might be a bug on the Client Library but I want to check first if someone else performed this successfully.</p>
  
  <p>I have been able to update the photo in the <a href="https://developers.google.com/admin-sdk/directory/v1/reference/users/photos/update" rel="nofollow noreferrer">"Try it!" section here</a> using the base64 encoded string returned by <code>pic = Base64.encode64(File.read('profilepic.png')).tr("+/", "-_")</code> and I have been able to do it using the PHP Client Library. Am I correct in thinking this is a bug?</p>