File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,13 @@ import (
6
6
"net/http"
7
7
"net/url"
8
8
"regexp"
9
+ "time"
9
10
10
11
"golang.org/x/oauth2"
11
12
"golang.org/x/oauth2/github"
12
13
"golang.org/x/xerrors"
13
14
15
+ "github.com/coder/coder/coderd/database"
14
16
"github.com/coder/coder/codersdk"
15
17
)
16
18
@@ -138,7 +140,9 @@ func (c *DeviceAuth) AuthorizeDevice(ctx context.Context) (*codersdk.GitAuthDevi
138
140
}
139
141
140
142
type ExchangeDeviceCodeResponse struct {
141
- * oauth2.Token
143
+ AccessToken string `json:"access_token"`
144
+ RefreshToken string `json:"refresh_token"`
145
+ ExpiresIn int `json:"expires_in"`
142
146
Error string `json:"error"`
143
147
ErrorDescription string `json:"error_description"`
144
148
}
@@ -175,7 +179,11 @@ func (c *DeviceAuth) ExchangeDeviceCode(ctx context.Context, deviceCode string)
175
179
if body .Error != "" {
176
180
return nil , xerrors .New (body .Error )
177
181
}
178
- return body .Token , nil
182
+ return & oauth2.Token {
183
+ AccessToken : body .AccessToken ,
184
+ RefreshToken : body .RefreshToken ,
185
+ Expiry : database .Now ().Add (time .Duration (body .ExpiresIn ) * time .Second ),
186
+ }, nil
179
187
}
180
188
181
189
func (c * DeviceAuth ) formatDeviceTokenURL (deviceCode string ) (string , error ) {
You can’t perform that action at this time.
0 commit comments