onelogin / onelogin-go-sdk

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

[BUG] Authentication fails because of incorrect API url #72

Closed stijndcl closed 1 year ago

stijndcl commented 1 year ago

The API docs mention that the correct url to authenticate is https://<subdomain>.onelogin.com/auth/oauth2/v2/token. This is easy to confirm by sending a request to it.

The SDK constructs this subdomain URL correctly when creating a client: https://github.com/onelogin/onelogin-go-sdk/blob/130b44035acebcfd3b2ee1ad3ef081914376791d/pkg/onelogin/api/client.go#L39-L40

However, the Authenticator completely ignores this and hardcodes the URL without region in the subdomain: https://github.com/onelogin/onelogin-go-sdk/blob/130b44035acebcfd3b2ee1ad3ef081914376791d/pkg/onelogin/authentication/authenticator.go#L40-L41

Hence, every request fails without much to do about it.

The subdomain URL should also be used for authentication (both generating & revoking tokens). It is generated one line before invoking the GenerateToken() method in NewClient(), so it can be passed in as a parameter.

Jmfwolf commented 1 year ago

Hey thank you for pointing this out and providing a fast PR.