Method to fetch the Device Flow access token once #367
OlivierRiberi
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
You can use |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
While implementing the Device Flow, I noticed that the only way to check if the user is logged in with the user code, is to use the
.poll()method.This method will call the token endpoint in a defined interval until the tokenSet is received or the user code is expired.
I'm using node-openid-client as part of an API-based website backend.
To get the up to date login status I need to handle the polling on the frontend side. So at a defined interval I'm calling a custom endpoint to get the status.
However
DeviceFlowHandledoes not provide an equivalent to.poll()to fetch the data once (so without the automatic polling, nor the error handling).Would it be possible to expose the token endpoint call process defined in
.poll()in another method for people like me that already handle the polling part elsewhere?Workaround
I have a custom endpoint to get the user code and start the polling from the backend. The status and the eventual tokenSet are saved in cache.
And I have another custom endpoint to get the status/tokenSet from the cache.
Issue:
By doing so, the polling stops when the tokenSet is returned or the user code is expired, but not if the user closes the browser window, moves away, or reloads the page to fetch another user code for example.
Beta Was this translation helpful? Give feedback.
All reactions