Skip to content

Commit 612a4a5

Browse files
authored
Merge pull request #37 from tchandelle/28-verification-uri-complete
Return the optional verification_uri_complete
2 parents ce77fe6 + b3b400d commit 612a4a5

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

device/device_flow.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ type CodeResponse struct {
4141
UserCode string
4242
// The verification URL where users need to enter the UserCode.
4343
VerificationURI string
44+
// The optional verification URL that includes the UserCode.
45+
VerificationURIComplete string
4446

4547
// The device verification code is 40 characters and used to verify the device.
4648
DeviceCode string
@@ -87,11 +89,12 @@ func RequestCode(c httpClient, uri string, clientID string, scopes []string) (*C
8789
}
8890

8991
return &CodeResponse{
90-
DeviceCode: resp.Get("device_code"),
91-
UserCode: resp.Get("user_code"),
92-
VerificationURI: verificationURI,
93-
Interval: intervalSeconds,
94-
ExpiresIn: expiresIn,
92+
DeviceCode: resp.Get("device_code"),
93+
UserCode: resp.Get("user_code"),
94+
VerificationURI: verificationURI,
95+
VerificationURIComplete: resp.Get("verification_uri_complete"),
96+
Interval: intervalSeconds,
97+
ExpiresIn: expiresIn,
9598
}, nil
9699
}
97100

device/device_flow_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,40 @@ func TestRequestCode(t *testing.T) {
9090
},
9191
},
9292
},
93+
{
94+
name: "with verification_uri_complete",
95+
args: args{
96+
http: apiClient{
97+
stubs: []apiStub{
98+
{
99+
body: "verification_uri=http://verify.me&interval=5&expires_in=99&device_code=DEVIC&user_code=123-abc&verification_uri_complete=http://verify.me/?code=123-abc",
100+
status: 200,
101+
contentType: "application/x-www-form-urlencoded; charset=utf-8",
102+
},
103+
},
104+
},
105+
url: "https://github.com/oauth",
106+
clientID: "CLIENT-ID",
107+
scopes: []string{"repo", "gist"},
108+
},
109+
want: &CodeResponse{
110+
DeviceCode: "DEVIC",
111+
UserCode: "123-abc",
112+
VerificationURI: "http://verify.me",
113+
VerificationURIComplete: "http://verify.me/?code=123-abc",
114+
ExpiresIn: 99,
115+
Interval: 5,
116+
},
117+
posts: []postArgs{
118+
{
119+
url: "https://github.com/oauth",
120+
params: url.Values{
121+
"client_id": {"CLIENT-ID"},
122+
"scope": {"repo gist"},
123+
},
124+
},
125+
},
126+
},
93127
{
94128
name: "unsupported",
95129
args: args{

0 commit comments

Comments
 (0)