7

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??

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

8 Comments

No, i just want to user the Google Mail Service , server-to-server. Just invoking the GMAIL REST Service from a java stand alone application [server side]. When i invoke the service i create a Google Credentials using a p12 file create just for this service.
You cannot use service accounts with consumer (non-Google Apps) accounts. You must use the Web Server flow or else the Installed App flow: developers.google.com/accounts/docs/OAuth2InstalledApp
It's also still not clear to me why you feel so strongly about using a service account. What can't you do with the web server flow?
There is no way to do this with a service account. You're effectively saying, how do I put the screw in the board with a hammer? Use the screwdriver...
Azimuts, Jay is right. "Service account" here means you're logging in as an account that's not a real (human) Google account. Such accounts cannot use Gmail, they are only used for services that aren't tied to a specific person (e.g. maps and search APIs, not drive, calendar, gmail, etc). One can use a service account with domain wide delegation to get access to any person in the domain (given the domain administrator whitelisting such access), but that's probably not what you want here (never works for @gmail.com accounts).
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.