Skip to content

Credentials don't use axios instance provided when creating the client #183

@wassil

Description

@wassil

Checklist

  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have upgraded to the latest version of OpenFGA and the issue still persists.
  • I have searched the Slack community and have not found a suitable solution or answer.
  • I agree to the terms within the OpenFGA Code of Conduct.

Description

I'm using a custom axios client to initialize OpenFgaClient, because our code runs in a VPC and requests need to go through proxy.
I found out that "credentails" are using default axios client, so it's unusable in our case.
Not sure if this is a bug or a feature requests, but it seems reasonable that the axios instance provided will be used for all requests.

To be exact, function refreshAccessToken:

}, globalAxios);

It should be using this.axios.
Further, the SDK calls Credentials.init, so it never sets the axios instance https://github.com/openfga/js-sdk/blob/main/base.ts#L51
I guess you could just add an extra parameter for init with axios.

If needed I can make a PR, but you will be a lot faster than me.

Expectation

Axios client provided should be used for all requests, including getting access token.

Reproduction

  1. Initialize the SDK with custom axios instance with e.g. logging interceptor.
  2. Make any call e.g. check
  3. See that the interceptor is not called for refreshing access token

OpenFGA SDK version

0.7.0

OpenFGA version

Auth0 FGA, not sure what version is that

SDK Configuration

With a custom axios client

Logs

No response

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions