You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Service account: Cannot set user to impersonate using GoogleCredential fromStream #1007
I'm trying to use a service account to automatically manage/create groups using the Directory API. When I try to use a service account with the credentials in the form of JSON and try to use the GoogleCredential.fromStream(...) call, there does not seem to be a way to set the user, and at least for the Admin API I cannot get calls to work without impersonating a user as I always get Forbidden (403) responses.
Using the GoogleCredential Builder seems to work fine with the PKCS12 formatted key as long as I set the user, but your docs and console seem to recommend to use the JSON formatted credential file.
Have I missed something, or is this functionality not available without using the builder?
Did you get a response on this issue?
Am facing the exact same thing. I wonder how one can set a service account ID whilst building GoogleCredential fromStream.
Activity
ejona86 commentedon Apr 14, 2016
How are you going about setting the user in the PKCS12 case?
WilsonGiese commentedon Apr 25, 2016
The builder itself has a set method
See https://developers.google.com/api-client-library/java/google-api-java-client/reference/1.19.1/com/google/api/client/googleapis/auth/oauth2/GoogleCredential.Builder#setServiceAccountUser(java.lang.String)
abhishek-choudhury commentedon Jun 20, 2016
Hey Wilson,
Did you get a response on this issue?
Am facing the exact same thing. I wonder how one can set a service account ID whilst building GoogleCredential fromStream.
WilsonGiese commentedon Jun 20, 2016
@abhishek-choudhury No, I never heard anything. I resorted to using the builder with a PKCS12 file.
abhishek-choudhury commentedon Jun 20, 2016
@WilsonGiese Thanks for your response Wilson!
I'll go back to P12 too in that case.
netp-dany commentedon Dec 1, 2016
Hi,
There is a work around, please have a look at the code below.
In case you really need to use json.
sanbornick commentedon Mar 1, 2017
JSON all the things! The console will issue JSON by default and make you dig for P12's. Lets go future! Except here. Don't look here.
This issue has only been open for a year I guess...
nddipiazza commentedon Jul 27, 2017
@netp-dany awesome! i've been looking for hours for an example. aka you're a f*king genius
nbali commentedon Jan 6, 2018
Will one of the PRs aimed at solving this will be merged? #1036 and/or #1079?
googleapis#1007 - adding option to impersonate a user with backward c…
chingor13 commentedon Sep 12, 2018
Fixed in #1079