From 9095a51613032fc4f54e91b3c67c0a922d990bfb Mon Sep 17 00:00:00 2001 From: M Hickford Date: Fri, 22 Sep 2023 14:28:09 +0000 Subject: [PATCH] oauth2: clarify error if endpoint missing DeviceAuthURL Change-Id: I36eb5eb66099161785160f4f39ea1c7f64ad6e74 GitHub-Last-Rev: 31cfe8150fa630b67b8e0a75d5ebb8890f979a6d GitHub-Pull-Request: golang/oauth2#664 Reviewed-on: https://go-review.googlesource.com/c/oauth2/+/526302 Reviewed-by: Matthew Dempsky LUCI-TryBot-Result: Go LUCI Auto-Submit: Bryan Mills Reviewed-by: Bryan Mills --- deviceauth.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deviceauth.go b/deviceauth.go index f3ea99e1..85ef796f 100644 --- a/deviceauth.go +++ b/deviceauth.go @@ -3,6 +3,7 @@ package oauth2 import ( "context" "encoding/json" + "errors" "fmt" "io" "net/http" @@ -88,6 +89,10 @@ func (c *Config) DeviceAuth(ctx context.Context, opts ...AuthCodeOption) (*Devic } func retrieveDeviceAuth(ctx context.Context, c *Config, v url.Values) (*DeviceAuthResponse, error) { + if c.Endpoint.DeviceAuthURL == "" { + return nil, errors.New("endpoint missing DeviceAuthURL") + } + req, err := http.NewRequest("POST", c.Endpoint.DeviceAuthURL, strings.NewReader(v.Encode())) if err != nil { return nil, err