How to authenticate with Google Email Settings API using service account oauth2 Python client?

user3438152

I'm using Python 2.6 and the client library for Google API which I am trying to use to get authenticated access to email settings :

f = file(SERVICE_ACCOUNT_PKCS12_FILE_PATH, 'rb')
key = f.read()
f.close()
credentials = client.SignedJwtAssertionCredentials(SERVICE_ACCOUNT_EMAIL, key,      scope='https://apps-apis.google.com/a/feeds/emailsettings/2.0/', sub=user_email)

http = httplib2.Http()
http = credentials.authorize(http)
return discovery.build('email-settings', 'v2', http=http)

When I execute this code , I got the follwowing error: UnknownApiNameOrVersion: name: email-settings version: v2

What's the api name and version for email settingsV2? Is it possible to use it with service account? Regards

user3438152

I found the solution to get email settings using service account oauth2: Here is a example:

  SERVICE_ACCOUNT_EMAIL = ''
  SERVICE_ACCOUNT_PKCS12_FILE_PATH = ''
  EMAIL_SETTING_URI = "https://apps-apis.google.com/a/feeds/emailsettings/2.0/%s/%s/%s" 

 def fctEmailSettings():

    user_email = "[email protected]"
    f = file(SERVICE_ACCOUNT_PKCS12_FILE_PATH, 'rb')
    key = f.read()
    f.close()
    credentials = client.SignedJwtAssertionCredentials(SERVICE_ACCOUNT_EMAIL, key, scope='https://apps-apis.google.com/a/feeds/emailsettings/2.0/', sub=user_email)
    auth2token = OAuth2TokenFromCredentials(credentials)
    ESclient = EmailSettingsClient(domain='doamin.com')
    auth2token.authorize(ESclient)
    username = 'username'
    setting='forwarding'
    uri = ESclient.MakeEmailSettingsUri(username, setting)
    entry = ESclient.get_entry(uri = uri,  desired_class = GS.gdata.apps.emailsettings.data.EmailSettingsEntry)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Google Drive API Python Service Account Example

From Dev

How to get user email after OAUTH with Google API Python Client

From Dev

How to authenticate in Google Fusion Tables with Oauth2 in Dart?

From Dev

google oauth2 how to get private key for service account

From Dev

How to authenticate with login and password using OAuth2?

From Dev

How to authenticate client on multiple OAuth2 providers?

From Dev

Google OAuth2 with Service Account - specifying the user email to act on behalf of

From Dev

Using Email Settings API from app engine with service account

From Dev

Authenticate Chrome extension with non-Google API using Google account

From Dev

Google API OAuth2, Service Account, "error" : "invalid_grant"

From Dev

How to use a service account with Google's python api and drive?

From Dev

Use oauth2 service account to authenticate to Google API in python

From Dev

How to set the Google API user to impersonate using a Service Account (Ruby Client)?

From Dev

Google API access using Service Account oauth2client.client.CryptoUnavailableError: No crypto library available

From Dev

Use to Chrome Store Publishing API with OAuth2 Service Account

From Dev

How to change the google API "service account" name/email address

From Dev

How to use the Google Email Settings API and the OAuth2 for Apps Script Library to set email signatures for users in a Google Apps domain

From Dev

Move Google EmailSettings API python code from OAuth1 to OAuth2 service account

From Dev

Google OAuth2 Service Account HTTP/REST Authentication

From Dev

Get Token from Client Email and Private Key (Service Account) in Google

From Dev

How to authenticate google APIs with different service account credentials?

From Dev

Authenticate against Yammer API using Microsoft OAuth2

From Dev

Google Apps Email Settings API and oauth2.0 Credential with service account

From Dev

Google OAuth2 with Service Account - specifying the user email to act on behalf of

From Dev

How to Google OAuth2 to upload videos to 2 different YouTube account with a Python script

From Dev

Move Google EmailSettings API python code from OAuth1 to OAuth2 service account

From Dev

I am using google API Oauth2 for google sign-in on my website. How do i get the full name and email id variable from this code into my php code?

From Dev

Authenticate a Google PubSub POST request using OAuth2

From Dev

How to use Service Account to authenticate with Google Cloud SQL Java

Related Related

  1. 1

    Google Drive API Python Service Account Example

  2. 2

    How to get user email after OAUTH with Google API Python Client

  3. 3

    How to authenticate in Google Fusion Tables with Oauth2 in Dart?

  4. 4

    google oauth2 how to get private key for service account

  5. 5

    How to authenticate with login and password using OAuth2?

  6. 6

    How to authenticate client on multiple OAuth2 providers?

  7. 7

    Google OAuth2 with Service Account - specifying the user email to act on behalf of

  8. 8

    Using Email Settings API from app engine with service account

  9. 9

    Authenticate Chrome extension with non-Google API using Google account

  10. 10

    Google API OAuth2, Service Account, "error" : "invalid_grant"

  11. 11

    How to use a service account with Google's python api and drive?

  12. 12

    Use oauth2 service account to authenticate to Google API in python

  13. 13

    How to set the Google API user to impersonate using a Service Account (Ruby Client)?

  14. 14

    Google API access using Service Account oauth2client.client.CryptoUnavailableError: No crypto library available

  15. 15

    Use to Chrome Store Publishing API with OAuth2 Service Account

  16. 16

    How to change the google API "service account" name/email address

  17. 17

    How to use the Google Email Settings API and the OAuth2 for Apps Script Library to set email signatures for users in a Google Apps domain

  18. 18

    Move Google EmailSettings API python code from OAuth1 to OAuth2 service account

  19. 19

    Google OAuth2 Service Account HTTP/REST Authentication

  20. 20

    Get Token from Client Email and Private Key (Service Account) in Google

  21. 21

    How to authenticate google APIs with different service account credentials?

  22. 22

    Authenticate against Yammer API using Microsoft OAuth2

  23. 23

    Google Apps Email Settings API and oauth2.0 Credential with service account

  24. 24

    Google OAuth2 with Service Account - specifying the user email to act on behalf of

  25. 25

    How to Google OAuth2 to upload videos to 2 different YouTube account with a Python script

  26. 26

    Move Google EmailSettings API python code from OAuth1 to OAuth2 service account

  27. 27

    I am using google API Oauth2 for google sign-in on my website. How do i get the full name and email id variable from this code into my php code?

  28. 28

    Authenticate a Google PubSub POST request using OAuth2

  29. 29

    How to use Service Account to authenticate with Google Cloud SQL Java

HotTag

Archive