Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GMail REST API: Using Google Credentials Without Impersonate

Is it possible to use Google Credentials for GMAIL REST API without using impersonation??

In many examples of GMAIL REST API i see is mandatory to use an impersonation account associated to a domain and Google APPS. I just want to use GMAIL REST API api server-to-server :

f.e:

GoogleCredential  credential = new GoogleCredential.Builder().setTransport(httpTransport)
            .setJsonFactory(jsonFactory)
                         .setServiceAccountId(serviceAccountUserEmail)
                         **.setServiceAccountUser("[email protected])**
                         .setServiceAccountScopes(SCOPES)
                         .setServiceAccountPrivateKeyFromP12File(
                         new java.io.File(SERVICE_ACCOUNT_PKCS12_FILE_PATH))                                
                        .build();

The matter is that i don't have any domain and i use just a GMAIL account...but i don't get any way to authorize, for example : [email protected]

The servive acccount id [email protected]"; is a "client account" created with the [email protected]

This has no sense , i don't want to impersonate with no other account of another domain, and i don't get any way to authozize [email protected] .

Just only works, if you have an account to impersonate of other domain associated with Google Apps, and to get Google Apps...you need a domain.

Any advise??

like image 704
Azimuts Avatar asked Mar 30 '15 07:03

Azimuts


People also ask

Can I use Gmail API for free?

Gmail API is available for free, but it has certain daily usage limits for API calls. Daily usage: 1 billion API calls per day. Per User Rate Limit: 250 API calls per user per second.

How does OAuth 2.0 work in REST API?

In OAuth 2.0, the following three parties are involved: The user, who possesses data that is accessed through the API and wants to allow the application to access it. The application, which is to access the data through the API on the user's behalf. The API, which controls and enables access to the user's data.

Can a service account impersonate another service account?

For example, if a principal has the Service Account User role on a service account, and the service account has the Cloud SQL Admin role ( roles/cloudsql. admin ) on the project, then the principal can impersonate the service account to create a Cloud SQL instance.


1 Answers

You may just want to simply use OAuth 2.0 for Web Server Applications. Assuming you want the authorization for more than an hour, you can use refresh tokens.

like image 183
Jay Lee Avatar answered Sep 29 '22 19:09

Jay Lee