File tree Expand file tree Collapse file tree 2 files changed +28
-6
lines changed Expand file tree Collapse file tree 2 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ package api
44type AccessToken struct {
55 // The token value, typically a 40-character random string.
66 Token string
7+ // The refresh token value, associated with the access token.
8+ RefreshToken string
79 // The token type, e.g. "bearer".
810 Type string
911 // Space-separated list of OAuth scopes that this token grants.
@@ -14,9 +16,10 @@ type AccessToken struct {
1416func (f FormResponse ) AccessToken () (* AccessToken , error ) {
1517 if accessToken := f .Get ("access_token" ); accessToken != "" {
1618 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" ),
2023 }, nil
2124 }
2225
Original file line number Diff line number Diff line change @@ -23,9 +23,28 @@ func TestFormResponse_AccessToken(t *testing.T) {
2323 },
2424 },
2525 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" ,
2948 },
3049 wantErr : nil ,
3150 },
You can’t perform that action at this time.
0 commit comments