Skip to content

Access token expires and causes exception every 10 hours src/OneLoginClient/OneLoginClient.cs #3

@keziashirazi98

Description

@keziashirazi98

Hi,

Thank you for your code it has provided great use to me! However, I have found a bug in src/OneLoginClient/OneLoginClient.cs.

Summary
My script uses this OneLoginClientDotNet package. It runs every hour. A 'NullReferenceException' is raised every 10 hours.

The code failure occurs inside src/OneLoginClient/OneLoginClient.cs:

  • The NullReferenceException is raised on line 97 (nextLink = result.Pagination.NextLink;) within the GetNextPages function
  • This is because the access token, used by the client to make an API call to OneLogin, expires every 10 hours and the same access token is still used until the http request returns a 'forbidden' response. This is described here.
  • On line 95 (var result = await GetResource<T>(nextLink);), the code generates an expired token after 10 hours.
  • This forbids access for the client to OneLogin, which is shown by the 'forbidden' response (401) from OneLogin in the ParseHttpResponse() function
  • This returns a null var result and causes the NullReferenceException to be thrown.
  • My script then fails due to the NullReferenceException and stops running. It is then automatically rerun by kubernetes and the script runs fine as a new access token is generated.

What is the current bug behavior?
A NullReferenceException is raised every 10 hours due to access token expiring

What is the expected correct behavior?
A new token would be generated every 9-10 hours before the access token expires to avoid the Exception being thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions