Fix undefined tokenProvider when access token is provided. #642
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
When using the ManagementClient,
tokenProvider
is expected to be a member of theoptions
object which is passed to various Managers such as theJobsManager
. However, when the ManagementClient is configured with only a domain and a token,tokenProvider
is not assigned to the options object which results in an error when a Manager attempts to accessoptions.tokenProvider.getAccessToken
becausetokenProvider
is undefined.e.g. https://github.com/auth0/node-auth0/blob/master/src/management/JobsManager.js#L142
This PR moves the line which assigns the
tokenProvider
to the options object out of anif
statement so that the assignment is performed on all code paths.Testing
Test this by using the ManagementClient with an access token as specified in the docs.
https://auth0.github.io/node-auth0/module-management.ManagementClient.html
Then attempt to use a method provided by the
JobsManager
. e.g. import users jobPreviously, this would throw an error:
But with this change, it should start the job as expected.
Checklist