forked from Mirrors/oauth2
google: update error return format.
Change-Id: Id2cd28484e3724eee98757c2f40cbb237dee2c75
This commit is contained in:
parent
74f89b5575
commit
87e4e25ded
|
@ -29,8 +29,7 @@ func ExchangeToken(ctx context.Context, endpoint string, request *STSTokenExchan
|
|||
data.Set("scope", strings.Join(request.Scope, " "))
|
||||
opts, err := json.Marshal(options)
|
||||
if err != nil {
|
||||
fmt.Errorf("oauth2/google: failed to marshal additional options: %v", err)
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("oauth2/google: failed to marshal additional options: %v", err)
|
||||
}
|
||||
|
||||
data.Set("options", string(opts))
|
||||
|
@ -39,8 +38,8 @@ func ExchangeToken(ctx context.Context, endpoint string, request *STSTokenExchan
|
|||
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", endpoint, strings.NewReader(encodedData))
|
||||
if err != nil {
|
||||
fmt.Errorf("oauth2/google: failed to properly build http request: %v", err)
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("oauth2/google: failed to properly build http request: %v", err)
|
||||
|
||||
}
|
||||
for key, list := range headers {
|
||||
for _, val := range list {
|
||||
|
@ -52,8 +51,7 @@ func ExchangeToken(ctx context.Context, endpoint string, request *STSTokenExchan
|
|||
resp, err := client.Do(req)
|
||||
|
||||
if err != nil {
|
||||
fmt.Errorf("oauth2/google: invalid response from Secure Token Server: %v", err)
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("oauth2/google: invalid response from Secure Token Server: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
|
@ -62,8 +60,8 @@ func ExchangeToken(ctx context.Context, endpoint string, request *STSTokenExchan
|
|||
for bodyJson.More() {
|
||||
err = bodyJson.Decode(&stsResp)
|
||||
if err != nil {
|
||||
fmt.Errorf("oauth2/google: failed to unmarshal response body from Secure Token Server: %v", err)
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("oauth2/google: failed to unmarshal response body from Secure Token Server: %v", err)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue