From 8f0cf1cd0e2aa882ac6163e3958a5d4efdc6bbaa Mon Sep 17 00:00:00 2001 From: clgillis Date: Wed, 12 Sep 2018 14:43:39 -0400 Subject: [PATCH 1/3] b2_authorize_user use AppKeyID and LoginInfo.AccountID for everthing else --- b2.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/b2.go b/b2.go index 1d54d36..7cb4d56 100644 --- a/b2.go +++ b/b2.go @@ -316,7 +316,7 @@ func (c *Client) BucketByName(name string, createIfNotExists bool) (*BucketInfo, // Buckets returns a list of buckets sorted by name. func (c *Client) Buckets() ([]*BucketInfo, error) { res, err := c.doRequest("b2_list_buckets", map[string]interface{}{ - "accountId": c.accountID, + "accountId": c.LoginInfo.AccountID, }) if err != nil { return nil, err @@ -352,7 +352,7 @@ func (c *Client) CreateBucket(name string, allPublic bool) (*BucketInfo, error) bucketType = "allPublic" } res, err := c.doRequest("b2_create_bucket", map[string]interface{}{ - "accountId": c.accountID, + "accountId": c.LoginInfo.AccountID, "bucketName": name, "bucketType": bucketType, }) @@ -379,7 +379,7 @@ func (c *Client) CreateBucket(name string, allPublic bool) (*BucketInfo, error) // becomes invalid and any other calls will fail. func (b *Bucket) Delete() error { res, err := b.c.doRequest("b2_delete_bucket", map[string]interface{}{ - "accountId": b.c.accountID, + "accountId": b.c.LoginInfo.AccountID, "bucketId": b.ID, }) if err != nil { From 63c2857d6ca861413f8c8034be498287ddaca2d2 Mon Sep 17 00:00:00 2001 From: clgillis Date: Wed, 12 Sep 2018 15:38:48 -0400 Subject: [PATCH 2/3] fix reference to loginInfo.AccountID --- b2.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/b2.go b/b2.go index 7cb4d56..860b38d 100644 --- a/b2.go +++ b/b2.go @@ -316,7 +316,7 @@ func (c *Client) BucketByName(name string, createIfNotExists bool) (*BucketInfo, // Buckets returns a list of buckets sorted by name. func (c *Client) Buckets() ([]*BucketInfo, error) { res, err := c.doRequest("b2_list_buckets", map[string]interface{}{ - "accountId": c.LoginInfo.AccountID, + "accountId": c.loginInfo.Load().(*LoginInfo).AccountID, }) if err != nil { return nil, err @@ -352,7 +352,7 @@ func (c *Client) CreateBucket(name string, allPublic bool) (*BucketInfo, error) bucketType = "allPublic" } res, err := c.doRequest("b2_create_bucket", map[string]interface{}{ - "accountId": c.LoginInfo.AccountID, + "accountId": c.loginInfo.Load().(*LoginInfo).AccountID, "bucketName": name, "bucketType": bucketType, }) @@ -379,7 +379,7 @@ func (c *Client) CreateBucket(name string, allPublic bool) (*BucketInfo, error) // becomes invalid and any other calls will fail. func (b *Bucket) Delete() error { res, err := b.c.doRequest("b2_delete_bucket", map[string]interface{}{ - "accountId": b.c.LoginInfo.AccountID, + "accountId": b.c.loginInfo.Load().(*LoginInfo).AccountID, "bucketId": b.ID, }) if err != nil { From 2056054595c27081e062776333fd593dbbc6f096 Mon Sep 17 00:00:00 2001 From: clgillis Date: Wed, 12 Sep 2018 20:26:44 -0400 Subject: [PATCH 3/3] fixed b2 issue --- b2.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/b2.go b/b2.go index 860b38d..91b50e7 100644 --- a/b2.go +++ b/b2.go @@ -236,7 +236,7 @@ func (c *Client) doRequest(endpoint string, params map[string]interface{}) (*htt return nil, err } // Reduce debug log noise - delete(params, "accountID") + // delete(params, "accountID") delete(params, "bucketID") apiURL := c.loginInfo.Load().(*LoginInfo).ApiURL @@ -298,7 +298,7 @@ func (c *Client) BucketByID(id string) *Bucket { // found and createIfNotExists is true, CreateBucket is called with allPublic set // to false. Otherwise, an error is returned. func (c *Client) BucketByName(name string, createIfNotExists bool) (*BucketInfo, error) { - bs, err := c.Buckets() + bs, err := c.Buckets(name) if err != nil { return nil, err } @@ -314,9 +314,10 @@ func (c *Client) BucketByName(name string, createIfNotExists bool) (*BucketInfo, } // Buckets returns a list of buckets sorted by name. -func (c *Client) Buckets() ([]*BucketInfo, error) { +func (c *Client) Buckets(name string) ([]*BucketInfo, error) { res, err := c.doRequest("b2_list_buckets", map[string]interface{}{ "accountId": c.loginInfo.Load().(*LoginInfo).AccountID, + "bucketName": name, }) if err != nil { return nil, err