diff --git a/device/device_flow.go b/device/device_flow.go index 82fc479..e6a6ee9 100644 --- a/device/device_flow.go +++ b/device/device_flow.go @@ -72,6 +72,7 @@ func RequestCode(c httpClient, uri string, clientID string, scopes []string) (*C if resp.StatusCode == 401 || resp.StatusCode == 403 || resp.StatusCode == 404 || resp.StatusCode == 422 || (resp.StatusCode == 200 && verificationURI == "") || + (resp.StatusCode == 400 && resp.Get("error") == "device_flow_disabled") || (resp.StatusCode == 400 && resp.Get("error") == "unauthorized_client") { return nil, ErrUnsupported } diff --git a/device/device_flow_test.go b/device/device_flow_test.go index 238e14c..b43d18c 100644 --- a/device/device_flow_test.go +++ b/device/device_flow_test.go @@ -180,6 +180,33 @@ func TestRequestCode(t *testing.T) { }, }, }, + { + name: "device flow disabled", + args: args{ + http: apiClient{ + stubs: []apiStub{ + { + body: "error=device_flow_disabled", + status: 400, + contentType: "application/x-www-form-urlencoded; charset=utf-8", + }, + }, + }, + url: "https://github.com/oauth", + clientID: "CLIENT-ID", + scopes: []string{"repo", "gist"}, + }, + wantErr: "device flow not supported", + posts: []postArgs{ + { + url: "https://github.com/oauth", + params: url.Values{ + "client_id": {"CLIENT-ID"}, + "scope": {"repo gist"}, + }, + }, + }, + }, { name: "server error", args: args{