Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delegate credential using google script or javascript #1831

Closed
bertranddelcroix opened this issue Jun 19, 2024 · 2 comments
Closed

delegate credential using google script or javascript #1831

bertranddelcroix opened this issue Jun 19, 2024 · 2 comments
Labels
type: question Request for information or clarification. Not an issue.

Comments

@bertranddelcroix
Copy link

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 = "[email protected]"

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", [])

/----

@clundin25 clundin25 self-assigned this Jun 24, 2024
@clundin25
Copy link

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.

@clundin25 clundin25 removed their assignment Jun 24, 2024
@clundin25 clundin25 transferred this issue from googleapis/google-auth-library-python Jun 24, 2024
@danielbankhead
Copy link
Member

@danielbankhead danielbankhead added the type: question Request for information or clarification. Not an issue. label Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants