How do I call the gmail api in Spring Boot 2.x using a service account?

前端 未结 2 1194
暗喜
暗喜 2021-01-25 08:34

I have a GSuite service account configured to access corporate user gmail accounts, I have provided it with all of the privileges in the G Suite Admin console including Domain W

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-25 09:17

    Ok the answer was that you MUST specify a user when creating the credential. In the newer version of the API this call has been changed to: .createDelegated(). Just put the users email that you wish to impersonate there.

     GoogleCredential credential = GoogleCredential.fromStream(resourceAsStream).createDelegated("deusrex@mygenericdomain.com");
    

提交回复
热议问题