This repository has been archived by the owner on Jul 2, 2024. It is now read-only.
Make api/auth more suitable to be used as a dependency #256
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.
Hi!
I'd like to use the api/auth part of of this package as a dependency. Basically i made two things to make that easier:
The one-time code for initial device token generation can be optionally supplied via
RMAPI_DEVICE_CODE
. I think that's good for the non-interactive usage of rmapi as well.Instead of trying to authenticate with an expired user token,
userTokenExpires
checks if it is expired or expires soon. It seems like (I haven't really checked this thoroughly tbh) when the rmapi shell is started just before the current user token is about to expire, there is no re-auth mechanism. Hence this change would also be nice for shell users...To be able to work on this package on macOS Monterey with a M1 chip, i had to bump golang.org/x/sys to a newer version.
The PR is draft mode, because i'm not sure if there are differences regarding the authentication between the two API versions (See
TODO
inuserTokenExpires
). Since my rM Cloud account is on the newer API, i can't test it unfortunately.Is this still the case? I'd love to support you with testing/verification.
Br, Thomas