oauth2client.client.AccessTokenRefreshError:invalid_grant只在Docker中

我有相同的代码与相同的p12文件(选中md5总和),相同的account_email和相同的范围工作在一些计算机上,但不能在任何工作的计算机上的Docker容器中工作。 我的代码片段如下:

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) 

每当我尝试这在一个Docker容器内,我得到oauth2client.client.AccessTokenRefreshError: invalid_grantdiscovery.build行的oauth2client.client.AccessTokenRefreshError: invalid_grant 。 我想这可能与需要公开端口有关,但不知道我需要揭露,或者如果这是真正的问题。 有人有主意吗?

这听起来像是一个时钟问题。 Google的OAuth访问令牌有效期为一个小时(Google刷新令牌永久有效,您可以使用它们检索新的访问令牌)。 你可以validationDocker容器的时钟是否与主机同步(或设置为预期的时区?)。

请参阅: docker容器是否会自动与主机同步?

Interesting Posts