Python beginner here - I'm trying to program in python so I can change our users' signature for our organization. I'm having trouble following this guide.
The code examples are clear but how to get started is not. I vaguely understand that I need to use oauth2 like here, and fully understand how to create a token under the developers console.
Can someone give me a code snippet to connect using oauth2
with "Fake Token" and retrieve everyone's account email and their signature settings? This would help me use other methods from the classes mentioned in the DOC.
Under the General tab in Settings, scroll down till you find the Signature section. Click inside the Signature edit box and go to Edit > Paste to paste in the HTML you have stored in the clipboard (Command+V). Click “Save Changes” right below the Signature edit box.
There are a few examples that demonstrate using python and assume that you have installed the following modules: gdata, oauth2client, and/or apiclient. Use these links to install them Google API Client Library for Python and Google Data Python Library.
There are samples spread across the API and developer site but these were the most helpful.
The documentation has a code snippet that shows how to modify a Signature using Python libs.
import gdata.apps.emailsettings.client
...
client = gdata.apps.emailsettings.client.EmailSettingsClient(domain='yourdomain')
client.ClientLogin(email='adminUsername@yourdomain', password='adminPassword', source='your-apps')
client.UpdateSignature(username='liz', signature="Liz Jones - (+1) 619-555-5555" +
"Accounts Management, A&Z LTD.")
Here is an example of getting your Signature for your domain (thanks to this post)
credentials = get_credentials()
client = gdata.apps.emailsettings.client.EmailSettingsClient(domain='yourdomain.com')
client.auth_token = gdata.gauth.OAuth2TokenFromCredentials(credentials)
val = client.RetrieveSignature(username="yourusername")
The next step is to get a list of all users for the domain and iterate over the list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With