oauth2client.client.AccessTokenRefreshError: invalid_grant Only in Docker

I have the same code with the same p12 file (checked md5 sums), same account_email, and same scope working on a number of computers, but not working in Docker containers on any of the working computers. My code snippet is as follows:

with open(self.pkcs12_file_path, 'rb') as f: key = f.read() scope = ['https://www.googleapis.com/auth/bigquery', 'https://www.googleapis.com/auth/cloud-platform'] credentials = SignedJwtAssertionCredentials(self.account_email, key, scope) http = httplib2.Http() self.http = credentials.authorize(self.http) service = discovery.build('bigquery', 'v2', http=self.http)

Whenever I try this inside of a Docker container, I get oauth2client.client.AccessTokenRefreshError: invalid_grant at the discovery.build line. I'm thinking it might have something to do with needing to expose ports, but have no idea which I'd need to expose, or if that's the actual problem. Anyone have any ideas?


This sounds like a clock issue. Google's OAuth access tokens are valid for one hour (Google refresh tokens are valid forever and you can use them to retrieve a new access token). Can you verify that the Docker container's clock is synced with the host machine (or set to your expected time zone?).

See: Will docker container auto sync time with the host machine?

人吐槽 人点赞



用户名: 密码:
验证码: 匿名发表


查看评论:oauth2client.client.AccessTokenRefreshError: invalid_grant Only in Docker