My requirement is i need add image signature to the Gmail users dynamically.
FYI: The following is the process i followed
created project in google console
created Oauth Client ID in the following way
Application Type: web
Authorised JavaScript origins: http://localhost
Authorised redirect URIs: http://localhost:3000
downloaded as client_request.json
The code is given below
'''
from apiclient import discovery
from googleapiclient.discovery import build
from googleapiclient import discovery
from httplib2 import Http
from oauth2client import file, client, tools
from oauth2client.tools import argparser, run_flow
args = argparser.parse_args()
from oauth2client.file import Storage
SCOPES = 'https://www.googleapis.com/auth/gmail.settings.basic'
STORAGE = Storage('credentials.storage')
credentials = STORAGE.get()
creds =None
args.noauth_local_webserver = True
http = httplib2.Http()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
creds = tools.run_flow(flow, STORAGE,http=http)
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
signature = {'signature':'<img src="https://server:8000/test.png" alt="asaa" width="100" height="100">'}
rsp = GMAIL.users().settings().sendAs().patch(userId='me',
sendAsEmail=address['sendAsEmail'], body=signature).execute()
print("Signature changed to '%s'" % rsp['signature']) '''
I am stuck with 2 issues:
1) After i run the above code it is generating the following URL
It is pointing to 8080 inspite specifying 3000 as redirection port
2) I am unable to generate dynamic URL which should be unique for every web request
Pls suggest the way forward
Thanks