Skip to content

Commit

Permalink
timeout checks and errs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jmfwolf committed Jul 31, 2023
1 parent 92c13f2 commit 8e0c5a4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/onelogin/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,20 @@ func NewClient() (*Client, error) {
subdomain := os.Getenv("ONELOGIN_SUBDOMAIN")
old := fmt.Sprintf("https://%s.onelogin.com", subdomain)
authenticator := authentication.NewAuthenticator(subdomain)
timeout := os.Getenv("ONELOGIN_TIMEOUT")
if timeout == "" || timeout == nil {
timeoutStr := os.Getenv("ONELOGIN_TIMEOUT")
timeout, err := strconv.Atoi(timeoutStr)
if err != nil || timeout <= 0 {
timeout = 10
}
timeout := time.Second * timeout
timeoutDuration := time.Second * time.Duration(timeout)
err := authenticator.GenerateToken()
if err != nil {
return nil, err
}

return &Client{
HttpClient: http.Client{
Timeout: timeout,
Timeout: timeoutDuration,
},
Auth: authenticator,
OLdomain: old,
Expand Down

0 comments on commit 8e0c5a4

Please sign in to comment.