Skip to content

Commit

Permalink
Fail fast when request to /.well-known/oauth-authorization-server fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
php-coder committed Dec 6, 2017
1 parent a5c8037 commit 51e0daf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/cmd/util/tokencmd/request_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,18 @@ func (o *RequestTokenOptions) SetDefaultOsinConfig() error {
if err != nil {
return err
}
resp, err := request(rt, strings.TrimRight(o.ClientConfig.Host, "/")+oauthMetadataEndpoint, nil)

requestURL := strings.TrimRight(o.ClientConfig.Host, "/") + oauthMetadataEndpoint
resp, err := request(rt, requestURL, nil)
if err != nil {
return err
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("couldn't get %v: unexpected response status %v", requestURL, resp.StatusCode)
}

metadata := &util.OauthAuthorizationServerMetadata{}
if err := json.NewDecoder(resp.Body).Decode(metadata); err != nil {
return err
Expand Down

0 comments on commit 51e0daf

Please sign in to comment.