-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Acquire with device code interval fix #3553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Acquire with device code interval fix #3553
Conversation
|
Fixed the failing test cases and linting errors and I think the pull request is ready for review by the team |
|
|
||
| if (response.body && response.body.error === Constants.AUTHORIZATION_PENDING) { | ||
| // user authorization is pending. Sleep for polling interval and try again | ||
| this.logger.info(response.body.error_description || "no_error_description"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer something more meaningful here. Also, errors should be logged using this.logger.error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced the "no_error_description" with "Authorization pending. Continue polling.", the response description is still most meaningful here as it is phrased like "AADSTS70016: OAuth 2.0 device flow error. Authorization is pending. Continue polling. Trace ID: 01707a0c-640b-4049-8cbb-ee2304dc0700 Correlation ID: 78b0fdfc-dd0e-4dfb-b13a-d316333783f6 Timestamp: 2020-03-26 22:54:14Z" with a lot of useful information for debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message itself does not seem appropriate to categorize as an error message, I still think this.logger.info is the better categorization of the message.
|
|
||
| await delay(pollingIntervalMilli); | ||
| } else { | ||
| return response.body; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a verbose log message here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
| * @param t number | ||
| * @param value T | ||
| */ | ||
| function delay<T>(t: number, value?: T): Promise<T | void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be defined somewhere more easily reusable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this function and continuePolling are defined in different ways. I would propose they are both added as members of this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to making them class functions. delay can also be a utility function instantiated as needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the delay function to the TimeUtils utility class and made continuePolling a member of the class.
- make the continuePolling function a class member - move the delay function to the TimeUtils utility - add a more descriptive polling alternate message - add a verbose message on polling completion
This is a proposal. I can't get this repo to work locally yet! Lerna doesn't get installed in my VM.
Something similar to this would:
Fix #3476