Skip to content

Commit 3eae5e5

Browse files
aaronstaleykarandeep-johar
authored andcommitted
Update SDK to latest stone spec (#57)
* full patch with tests: * simplified * fix fmt_type to get things compiling * drop missing import * simpler union decoding * update sdk version * update api spec to latest version (#2) * force SDK version update * fix basd commit in types
1 parent 302f2cc commit 3eae5e5

File tree

12 files changed

+3778
-759
lines changed

12 files changed

+3778
-759
lines changed

dropbox/auth/types.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ func (u *AccessError) UnmarshalJSON(body []byte) error {
7979
// AuthError : Errors occurred during authentication.
8080
type AuthError struct {
8181
dropbox.Tagged
82+
// MissingScope : The access token does not have the required scope to
83+
// access the route.
84+
MissingScope *TokenScopeError `json:"missing_scope,omitempty"`
8285
}
8386

8487
// Valid tag values for AuthError
@@ -88,9 +91,32 @@ const (
8891
AuthErrorInvalidSelectAdmin = "invalid_select_admin"
8992
AuthErrorUserSuspended = "user_suspended"
9093
AuthErrorExpiredAccessToken = "expired_access_token"
94+
AuthErrorMissingScope = "missing_scope"
9195
AuthErrorOther = "other"
9296
)
9397

98+
// UnmarshalJSON deserializes into a AuthError instance
99+
func (u *AuthError) UnmarshalJSON(body []byte) error {
100+
type wrap struct {
101+
dropbox.Tagged
102+
}
103+
var w wrap
104+
var err error
105+
if err = json.Unmarshal(body, &w); err != nil {
106+
return err
107+
}
108+
u.Tag = w.Tag
109+
switch u.Tag {
110+
case "missing_scope":
111+
err = json.Unmarshal(body, &u.MissingScope)
112+
113+
if err != nil {
114+
return err
115+
}
116+
}
117+
return nil
118+
}
119+
94120
// InvalidAccountTypeError : has no documentation (yet)
95121
type InvalidAccountTypeError struct {
96122
dropbox.Tagged
@@ -186,3 +212,16 @@ func NewTokenFromOAuth1Result(Oauth2Token string) *TokenFromOAuth1Result {
186212
s.Oauth2Token = Oauth2Token
187213
return s
188214
}
215+
216+
// TokenScopeError : has no documentation (yet)
217+
type TokenScopeError struct {
218+
// RequiredScope : The required scope to access the route.
219+
RequiredScope string `json:"required_scope"`
220+
}
221+
222+
// NewTokenScopeError returns a new TokenScopeError instance
223+
func NewTokenScopeError(RequiredScope string) *TokenScopeError {
224+
s := new(TokenScopeError)
225+
s.RequiredScope = RequiredScope
226+
return s
227+
}

0 commit comments

Comments
 (0)