onelogin / onelogin-go-sdk

golang sdk for onelogin apis
MIT License
10 stars 24 forks source link

Infinite loop when getting 401 #54

Closed zinaliker closed 1 year ago

zinaliker commented 2 years ago

Hi, I send my requests with bearer authorization method. (API Credentials) In case I get 401 there is an infinite loop to generate a new bearer token We may try one more time but why forever?

Thanks in advanced

case resp.StatusCode == http.StatusUnauthorized, resp.StatusCode == http.StatusForbidden:

if resourceRequest.AuthMethod == "bearer" {
    if err := setBearerToken(svc); err != nil {
        return nil, nil, err
    }
    return svc.executeHTTP(req, resourceRequest)
}

return nil, nil, customerrors.OneloginErrorWrapper(svc.ErrorContext, errors.New("unauthorized"))
bzvestey commented 2 years ago

Yest, this is definitely an over site in the code, we see about getting it added to the backlog.

For reference, here is a link to the line of code that is affected: https://github.com/onelogin/onelogin-go-sdk/blob/967237cfc038873d89e339fcc4f2d90a6cbf9983/pkg/services/olhttp/olrequest.go#L235

Jmfwolf commented 1 year ago

Is this issue still occuring with the newest Version?