My requirement is using python we want to add image as gmail signature. once the image is clicked we want to redirect to video file.
I tried this manually and was successful to add signature with the following steps:
- Open google docs and uploaded an image
- Added hyperlink to the image
- Now copied the image into gmail signature section
- Once i click on the image it is sucessfully redirected to video file.
Using python, i want to achieve this in dynamic way
- I created the google drive credentials
- Enabled the google docs API
- Able to read the docs data
- Now, iam stuck how to add text as signature.
I am trying with the below approach
SCOPES = ['https://www.googleapis.com/auth/gmail.settings.basic','https://www.googleapis.c om/auth/gmail.labels','https://www.googleapis.com/auth/gmail.send']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', SCOPES)
GMAIL = discovery.build('gmail', 'v1', http=creds.authorize(Http()))
addresses = GMAIL.users().settings().sendAs().list(userId='me',
fields='sendAs(isPrimary,sendAsEmail)').execute().get('sendAs')
for address in addresses:
if address.get('isPrimary'):
break
rsp = GMAIL.users().settings().sendAs().patch(userId='me',
sendAsEmail=address['sendAsEmail'], body=DATA).execute()
print("Signature changed to '%s'" % rsp['signature'])
The error am getting is
"code": 401, "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential
Pls suggest the way forward
Thanks vijay