Open bertranddelcroix opened 1 week ago
I found a tutorial article in the site internet for a delegate credential .
Here, I don't know the language in PHP. Is there a way to convert from this language to google script (GAS) or javascript ? otherwise how to do it?
Here is the small function in php (?) below
/----
from googleapiclient import discovery from httplib2 import Http from oauth2client import file, client, tools from google.oauth2 import service_account
SCOPES = ['https://www.googleapis.com/auth/gmail.settings.basic'] SERVICE_ACCOUNT_FILE = 'the-downloaded-keyfile.json'
// # The user we want to "impersonate" USER_EMAIL = "someone@yourdomain.com"
credentials = service_account.Credentials.\ from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES) delegated_credentials = credentials.with_subject(USER_EMAIL)
service = discovery.build('gmail', 'v1', credentials=delegated_credentials)
send_as_addresses = service.users().settings().sendAs().\ list(userId=USER_EMAIL, fields="sendAs(isPrimary,sendAsEmail)")
addresses = send_as_addresses.execute().get("sendAs", [])
This sample code is Python (not PHP).
I'm going to route this to the Javascript repository so this can receive help from someone familiar with javascript.
I found a tutorial article in the site internet for a delegate credential .
Here, I don't know the language in PHP. Is there a way to convert from this language to google script (GAS) or javascript ? otherwise how to do it?
Here is the small function in php (?) below
/----
from googleapiclient import discovery from httplib2 import Http from oauth2client import file, client, tools from google.oauth2 import service_account
SCOPES = ['https://www.googleapis.com/auth/gmail.settings.basic'] SERVICE_ACCOUNT_FILE = 'the-downloaded-keyfile.json'
// # The user we want to "impersonate" USER_EMAIL = "someone@yourdomain.com"
credentials = service_account.Credentials.\ from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES) delegated_credentials = credentials.with_subject(USER_EMAIL)
service = discovery.build('gmail', 'v1', credentials=delegated_credentials)
send_as_addresses = service.users().settings().sendAs().\ list(userId=USER_EMAIL, fields="sendAs(isPrimary,sendAsEmail)")
addresses = send_as_addresses.execute().get("sendAs", [])
/----