Skip to content

Commit

Permalink
Fixed MFA not reading error; hiding oauth url containing credentials (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rockspore authored Aug 20, 2020
1 parent a0d08ef commit 9dd1e39
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apigee/edge_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ func NewEdgeClient(o *EdgeClientOptions) (*EdgeClient, error) {
if e != nil {
return nil, e
}
if o.MgmtURL == defaultBaseURL || c.auth.MFAToken != "" {
if o.MgmtURL == defaultBaseURL || o.Auth.MFAToken != "" {
c.auth.MFAToken = o.Auth.MFAToken
e = c.getOAuthToken()
if e != nil {
return nil, e
Expand Down Expand Up @@ -290,7 +291,12 @@ func (c *EdgeClient) getOAuthToken() error {
defer res.Body.Close()
}
if err := CheckResponse(res); err != nil {
return err
var errorResponse *ErrorResponse
if errors.As(err, &errorResponse) {
return fmt.Errorf("%d %v", res.StatusCode, errorResponse.Message)
} else {
return fmt.Errorf("%d", res.StatusCode)
}
}
body := &OAuthResponse{}
if err := json.NewDecoder(res.Body).Decode(body); err != nil {
Expand Down

0 comments on commit 9dd1e39

Please sign in to comment.