my requirement is i need to authorize google users using OAuth2 dynamically upon every request and respond in personalized way.
The following is the process i followed## Heading ##
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:4000
downloaded as client_request.json
The following is the URL generated after running the below python code,
https://accounts.google.com/o/oauth2/auth?client_id=123456789123-lkhipfqkk6g224bnf7n9sfdsdfsdss.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A4000%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.settings.basic&access_type=offline&response_type=code
The issue we are facing is
The URL generated is same across all the users by which we are unable to process each request individually.
FYI: The following is the python code snippet
'''
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()
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:4000/test.png" alt="aaa" width="200" height="200">'}
rsp = GMAIL.users().settings().sendAs().patch(userId='me',
sendAsEmail=address['sendAsEmail'], body=signature).execute()
print("Signature changed to '%s'" % rsp['signature']) '''
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…