Skip to content

Commit 8bbdf9f

Browse files
committed
Fix expiresIn to be seconds and not nanoseconds
1 parent 1bfa802 commit 8bbdf9f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

common.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,22 @@ type Authorization struct {
7171
Client *Client `json:"-"`
7272
User User `json:"-"`
7373

74-
Code string `json:"-"`
75-
CreatedAt time.Time `json:"-"`
76-
AccessToken string `json:"access_token"`
77-
TokenType string `json:"token_type"`
78-
ExpiresIn time.Duration `json:"expires_in"`
79-
RefreshToken string `json:"refresh_token,omitempty"`
80-
Scope string `json:"scope"`
74+
Code string `json:"-"`
75+
CreatedAt time.Time `json:"-"`
76+
AccessToken string `json:"access_token"`
77+
TokenType string `json:"token_type"`
78+
ExpiresIn int64 `json:"expires_in"`
79+
RefreshToken string `json:"refresh_token,omitempty"`
80+
Scope string `json:"-"`
8181
}
8282

8383
func NewAuthorization(c *Client, u User, scope string, expiresIn time.Duration, refresh bool, code bool) (*Authorization, error) {
8484
a := Authorization{
8585
Client: c,
8686
User: u,
8787
CreatedAt: time.Now().UTC(),
88-
ExpiresIn: expiresIn,
88+
ExpiresIn: int64(expiresIn.Seconds()),
89+
TokenType: "bearer",
8990
Scope: scope,
9091
}
9192

@@ -132,7 +133,7 @@ func (a *Authorization) Refresh(scope string, expiresIn time.Duration) error {
132133
}
133134

134135
a.CreatedAt = time.Now().UTC()
135-
a.ExpiresIn = expiresIn
136+
a.ExpiresIn = int64(expiresIn.Seconds())
136137
a.Scope = strings.Join(finalScopes, " ")
137138

138139
if b, err := secureRandomBytes(64); err != nil {

0 commit comments

Comments
 (0)