Skip to content

Commit

Permalink
Add retry on get user
Browse files Browse the repository at this point in the history
  • Loading branch information
michalfranc-form3 committed Sep 30, 2019
1 parent 4da9dd4 commit 690ec1e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion auth0/auth0_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"time"

"github.com/parnurzeal/gorequest"
)
Expand Down Expand Up @@ -113,7 +115,11 @@ func (config *Config) getAuthenticationHeader() string {
// User
func (authClient *AuthClient) GetUserById(id string) (*User, error) {

resp, body, errs := gorequest.New().Get(authClient.config.apiUri+"users/"+id).Set("Authorization", authClient.config.getAuthenticationHeader()).End()
resp, body, errs := gorequest.New().
Get(authClient.config.apiUri+"users/"+id).
Set("Authorization", authClient.config.getAuthenticationHeader()).
Retry(2, 60*time.Second, http.StatusTooManyRequests).
End()

if resp.StatusCode >= 400 && resp.StatusCode != 404 {
return nil, fmt.Errorf("bad status code (%d): %s", resp.StatusCode, body)
Expand Down

0 comments on commit 690ec1e

Please sign in to comment.