Get support for banzaicloud/aliyun-sts-go-sdk

If you're new to LTH, please see our FAQ for more information on what it is we do.

Support Options

Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:

View Open Issues

Take a look to see if anyone else has experienced the same issue as you and if they managed to solve it.

Open an Issue

Make sure to read any relevant guidelines for opening issues on this repo before posting a new issue.

Sponsor directly

Check out the page and see if there are any options to sponsor this project or it's developers directly.

banzaicloud/aliyun-sts-go-sdk

Replacement for https://github.com/baiyubin/aliyun-sts-go-sdk

At least until https://github.com/baiyubin/aliyun-sts-go-sdk/pull/3 is merged.

Alibaba Cloud STS SDK for Go

GitHub Version Build Status Coverage Status Software License

关于

阿里云STS(Security Token Service) 是为阿里云账号(或RAM用户)提供短期访问权限管理的云服务。通过STS,您可以为联盟用户(您的本地账号系统所管理的用户)颁发一个自定义时效和访问权限的访问凭证。联盟用户可以使用STS短期访问凭证直接调用阿里云服务API,或登录阿里云管理控制台操作被授权访问的资源。

如果您需要快速掌握阿里云账号管理体系,请参看云栖社区

版本

  • 当前版本:1.0.0

运行环境

  • Go 1.5及以上

安装方法

  • 执行命令 go get github.com/baiyubin/aliyun-sts-go-sdk/sts

使用方法

package main

import (
	"fmt"
	"os"

	"github.com/baiyubin/aliyun-sts-go-sdk/sts"
)

func handleError(err error) {
	fmt.Println(err)
	os.Exit(-1)
}

const (
	accessKeyID     = "<AccessKeyID>"
	accessKeySecret = "<AccessKeySecret>"
	roleArn         = "<RoleArn>"
	sessionName     = "sts_demo"
)

func main() {
	stsClient := sts.NewClient(accessKeyID, accessKeySecret, roleArn, sessionName)

	resp, err := stsClient.AssumeRole(3600)
	if err != nil {
		handleError(err)
	}

	fmt.Printf("Credentials:\n")
	fmt.Printf("    AccessKeyID:%s\n", resp.Credentials.AccessKeyId)
	fmt.Printf("    AccessKeySecret:%s\n", resp.Credentials.AccessKeySecret)
	fmt.Printf("    SecurityToken:%s\n", resp.Credentials.SecurityToken)
	fmt.Printf("    Expiration:%s\n", resp.Credentials.Expiration)
}

作者

协议

Our Mission

We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.

Interesting Articles

Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated

p-e622a1a2