Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调用GetWithParams出错:Status Code: 403 Code: SignatureDoesNotMatch Message: The request signature we calculated does not match the signature you provided. Check your key and signing method. #264

Open
philipbo opened this issue Mar 22, 2018 · 4 comments
Assignees

Comments

@philipbo
Copy link

philipbo commented Mar 22, 2018

你好,感谢你贡献的第三方库,有个问题请教一下。

在获取image object信息时,在调用func (b *Bucket) GetWithParams(path string, params url.Values) (data []byte, err error)方法时,不幸的是出错时,出错误信息如下:Aliyun API Error: RequestId: 5AB3BEB300261B4583E490A5 Status Code: 403 Code: SignatureDoesNotMatch Message: The request signature we calculated does not match the signature you provided. Check your key and signing method.

但是调用func (b *Bucket) Info() (BucketInfo, error)就没有出错

调用代码, 结果出错,但是类库打印的GET URL地址是可以访问,并获取到图片的信息

func GetWithParams(destBucket string, path string, params url.Values) ([]byte, error) {
	client := NewClient()
	bucket := client.Bucket(destBucket)
	return bucket.GetWithParams(path, params)
}

调用代码, 结果正确:

func GetBucketInfo(destBucket string) (oss.BucketInfo, error) {
	client := NewClient()
	bucket := client.Bucket(destBucket)
	return bucket.Info()
}

client secure 设置为false也是出错

func NewClient() *oss.Client {
	return oss.NewOSSClient(oss.Beijing, false, accessKeyId, accessKeySecret, true)
}

期待你的回复,十分感谢!

@denverdino
Copy link
Owner

能给个例子吗?多谢

@philipbo
Copy link
Author

例子?

@denverdino
Copy link
Owner

错误的用例,我们复现一下

@philipbo
Copy link
Author

没办法提供你accessKeyId与accesskeySecret,不好意思

func test() {
	//oss中的图片地址
	// ossImgURL := "https://f.meishi.51baibao.com/youpin/test/000dd599-33b9-11e7-a0d7-00163e30b7a8.png"
	destBucket := "meishi-oss"
	dir := "youpin/test/"
	filename := "000dd599-33b9-11e7-a0d7-00163e30b7a8.png"
	path := fmt.Sprintf("%s%s", dir, filename)

	v := url.Values{}
	v.Add("x-oss-process", "image/info")

        //没办法提供accessKeyId, accesskeySecret, 权限太大
	accessKeyId := "aaaa"
	accesskeySecret := "bbbb"
	client := oss.NewOSSClient(oss.Beijing, false, accessKeyId, accesskeySecret, true)
	bucket := client.Bucket(destBucket)
	data, err := bucket.GetWithParams(path, v)

	//lib print
	//GET https://meishi-oss.oss-cn-beijing.aliyuncs.com/youpin/test/000dd599-33b9-11e7-a0d7-00163e30b7a8.png?x-oss-process=image%2Finfo ...
	if err != nil {
		panic(err)
	}

	log.Println("data: ", string(data))

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants