Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
288 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...