代码拉取完成,页面将自动刷新
package common
var creErr = "ClientError.CredentialError"
type CredentialIface interface {
GetSecretId() string
GetToken() string
GetSecretKey() string
// GetCredential retrieves all credential components (SecretId, SecretKey, Token) as a tuple.
// This method is designed to fetch all three credential values (SecretId, SecretKey, Token) at once.
// This is beneficial for atomic operations, preventing potential issues that could arise from
// separate calls where one credential element might be updated while others are not, leading to inconsistency.
GetCredential() (string, string, string)
// needRefresh() bool
// refresh()
}
// Credential is a basic implementation of the CredentialIface.
// It stores the SecretId, SecretKey, and Token directly.
// This struct is suitable for simple cases where credentials are known beforehand.
type Credential struct {
SecretId string // The SecretId for authentication.
SecretKey string // The SecretKey for signing requests.
Token string // The security token (optional).
}
func (c *Credential) needRefresh() bool {
return false
}
func (c *Credential) refresh() {
}
// NewCredential creates a new Credential instance with the given SecretId and SecretKey.
// This constructor is used when you don't have a security token.
func NewCredential(secretId, secretKey string) *Credential {
return &Credential{
SecretId: secretId,
SecretKey: secretKey,
}
}
// NewTokenCredential creates a new Credential instance with the given SecretId, SecretKey, and Token.
// This constructor is used when you have a security token.
func NewTokenCredential(secretId, secretKey, token string) *Credential {
return &Credential{
SecretId: secretId,
SecretKey: secretKey,
Token: token,
}
}
func (c *Credential) GetSecretKey() string {
return c.SecretKey
}
func (c *Credential) GetSecretId() string {
return c.SecretId
}
func (c *Credential) GetToken() string {
return c.Token
}
func (c *Credential) GetCredential() (string, string, string) {
return c.SecretId, c.SecretKey, c.Token
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。