Google Python Admin SDK using Oauth2 for a Service Account (Education Edition)-“oauth2client.client.AccessTokenRefreshError: access_denied” exception

╄→尐↘猪︶ㄣ 提交于 2019-12-05 10:03:58

Have you granted the third party client access in your Admin Console for your service account?

My to go instruction when it comes to setting up Service Account is the instruction Google has for Drive Api.

https://developers.google.com/drive/web/delegation

Take a look at the "Delegate domain-wide authority to your service account" part and see if you have completed those steps.

Maybe not OP's problem, but I had this same error and my issue was that I was setting the sub field in the credentials object

credentials = SignedJwtAssertionCredentials(SERVICE_ACCOUNT_EMAIL, key,
      scope=SCOPES, sub=**<DON'T SET ME>**)

If you're using domain-wide delegation, you need to not set a sub (because your "user" is the domain administrator.) The docs are a bit confusing on this point. I just removed the sub field and it worked for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!