Commit 1690dd9 1 parent 6b1e71c commit 1690dd9 Copy full SHA for 1690dd9
File tree 2 files changed +28
-6
lines changed
2 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ package api
4
4
type AccessToken struct {
5
5
// The token value, typically a 40-character random string.
6
6
Token string
7
+ // The refresh token value, associated with the access token.
8
+ RefreshToken string
7
9
// The token type, e.g. "bearer".
8
10
Type string
9
11
// Space-separated list of OAuth scopes that this token grants.
@@ -14,9 +16,10 @@ type AccessToken struct {
14
16
func (f FormResponse ) AccessToken () (* AccessToken , error ) {
15
17
if accessToken := f .Get ("access_token" ); accessToken != "" {
16
18
return & AccessToken {
17
- Token : accessToken ,
18
- Type : f .Get ("token_type" ),
19
- Scope : f .Get ("scope" ),
19
+ Token : accessToken ,
20
+ RefreshToken : f .Get ("refresh_token" ),
21
+ Type : f .Get ("token_type" ),
22
+ Scope : f .Get ("scope" ),
20
23
}, nil
21
24
}
22
25
Original file line number Diff line number Diff line change @@ -23,9 +23,28 @@ func TestFormResponse_AccessToken(t *testing.T) {
23
23
},
24
24
},
25
25
want : & AccessToken {
26
- Token : "ATOKEN" ,
27
- Type : "bearer" ,
28
- Scope : "repo gist" ,
26
+ Token : "ATOKEN" ,
27
+ RefreshToken : "" ,
28
+ Type : "bearer" ,
29
+ Scope : "repo gist" ,
30
+ },
31
+ wantErr : nil ,
32
+ },
33
+ {
34
+ name : "with refresh token" ,
35
+ response : FormResponse {
36
+ values : url.Values {
37
+ "access_token" : []string {"ATOKEN" },
38
+ "refresh_token" : []string {"AREFRESHTOKEN" },
39
+ "token_type" : []string {"bearer" },
40
+ "scope" : []string {"repo gist" },
41
+ },
42
+ },
43
+ want : & AccessToken {
44
+ Token : "ATOKEN" ,
45
+ RefreshToken : "AREFRESHTOKEN" ,
46
+ Type : "bearer" ,
47
+ Scope : "repo gist" ,
29
48
},
30
49
wantErr : nil ,
31
50
},
You can’t perform that action at this time.
0 commit comments