Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions tencentcloud/common/credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.

import json
import logging
import os
import time
import threading
Expand All @@ -35,6 +36,9 @@
from tencentcloud.common.profile.client_profile import ClientProfile


logger = logging.getLogger("tencentcloud_sdk_common")


class Credential(object):
"""Tencent Cloud Credentials.

Expand Down Expand Up @@ -71,7 +75,7 @@ def secretId(self):
@property
def secretKey(self):
return self.secret_key

def get_credential_info(self):
return self.secret_id, self.secret_key, self.token

Expand Down Expand Up @@ -158,7 +162,7 @@ def update_credential(self):
self._token = j["Token"]
self._expired_ts = j["ExpiredTime"]
except Exception as e:
# we shoud log it
logger.debug("fail to update credential because %s", e)
# maybe we should validate token to None as well
pass

Expand Down Expand Up @@ -244,7 +248,7 @@ def token(self):
with self._lock:
self._need_refresh()
return self._token

def get_credential_info(self):
with self._lock:
self._need_refresh()
Expand Down Expand Up @@ -460,7 +464,7 @@ def token(self):
with self._lock:
self._keep_fresh()
return self._token

def get_credential_info(self):
with self._lock:
self._keep_fresh()
Expand All @@ -469,7 +473,7 @@ def get_credential_info(self):
@property
def endpoint(self):
return self._endpoint

@endpoint.setter
def endpoint(self, endpoint):
self._endpoint = endpoint
Expand All @@ -481,12 +485,12 @@ def _keep_fresh(self):
def refresh(self):
if self._is_tke:
self._init_from_tke()

http_profile = HttpProfile()
http_profile.endpoint = self._endpoint
client_profile = ClientProfile()
client_profile.httpProfile = http_profile

common_client = CommonClient(credential=None, region=self._region, version=self._version,
service=self._service, profile=client_profile)
params = {
Expand Down