I am trying to update the signature of all the users of my company and have looked for days and cannot find any proper solution. I have used code snippets of python, Google apps script but none seem to work. Could anybody guide me to do build such application.
Asked
Active
Viewed 769 times
1
-
Please have a look at this SO post [How to use the Google Email Settings API and the OAuth2 for Apps Script Library to set email signatures for users in a Google Apps domain](http://stackoverflow.com/questions/30135119/how-to-use-the-google-email-settings-api-and-the-oauth2-for-apps-script-library) – Br. Sayan Mar 04 '16 at 05:02
-
I tried that but I could not make it work so I asked this in general not just for App script – Bishal Dangal Mar 04 '16 at 07:28
-
We need to know what you have tried? Where are you getting stuck? – Br. Sayan Mar 04 '16 at 10:06
-
It is accomplished with a PUT request to the this URL `PUT https://apps-apis.google.com/a/feeds/emailsettings/2.0/{domain name}/{username}/signature`. You can see [here](https://developers.google.com/admin-sdk/email-settings/#updating_a_signature) the table that shows the only property to be set when updating the signature. Check this [tutorial](https://ctrlq.org/code/20120-update-gmail-signature). – abielita Mar 04 '16 at 10:46
1 Answers
2
I solved it guys. Two sleepless night and bam...
import gdata.apps.emailsettings.client
from gdata.client import BadAuthentication
from gdata.client import RequestError
import urllib2
import requests
import json
# replace these values with yours
CONSUMER_KEY = 'XXXXXX'
CONSUMER_SECRET = 'XXXXXXXXXXXXXXXXXXX'
company_name = 'XXXXXXXXXXXXX'
admin_username = 'admin'
# request a 2-legged OAuth token
requestor_id = admin_username + '@' + CONSUMER_KEY
two_legged_oauth_token = gdata.gauth.TwoLeggedOAuthHmacToken(
CONSUMER_KEY, CONSUMER_SECRET, requestor_id)
#calling the emailsettings api
email_settings_client = gdata.apps.emailsettings.client.EmailSettingsClient(domain=CONSUMER_KEY)
email_settings_client.auth_token = two_legged_oauth_token email_settings_client.UpdateSignature(username='xxx.xxx@xxxx.com', signature='yor_signature')

Bishal Dangal
- 69
- 6
-
If you want to use a service account, which is probably simpler as long as you have admin rights, see Manage gmail signatures with python service account – Tim Richardson Apr 18 '16 at 10:39