-
Notifications
You must be signed in to change notification settings - Fork 596
feat(services/onedrive): add signer to utilize the refresh token #5733
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
Conversation
Behavior tests
I know the OneDrive behavior test is flaky. Fixing tests will take a few PRs and love. But it's also a good time to add new features:
cc @emliunix Feel free to try this branch if you find time! |
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 other changes look great—thank you!
root: String, | ||
access_token: String, | ||
client: HttpClient, | ||
pub struct OneDriveBackend { |
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 naming here needs to align with the scheme. Since our scheme is onedrive
instead of one_drive
, we must use Onedrive
instead of OneDrivew
.
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.
Ooops, good catch. I didn't mean to change this struct name. Will push a fix.
I kept a few modules that are not "public interfaces" with OneDriveXXX
because OneDrive is the product name. If you want to keep the same convention following the schema name, please ping me!
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.
Thank you, I really love this change!
Thanks for the ehancements, especially the addition of signer so that I can delete my custom token refresh logic. The code looks expecting one of 1. access_token or 2. refresh_token + client_id + optional client_secret to work. I tested the refresh_token + client_id case and found that I have to add scope "offline_access" right at OneDriveSigner::refresh_tokens() to get the next refresh_token, otherwise it will be a json deserialize error complaining misssing refresh_token.
Tried following 2 workarounds but all failed:
![]() |
@erickguan sure, look it's already fixed, I'll take a look once I got time. For the case of client_id and client_secret, per my test, the auth flow only requires client_id. So my understanding is to test if Graph API will reject on the presence of wrong client_secret. Because the code already requires refresh_token (implies the auth has completed beforehand), hence the secret is not used for auth flow here. |
Looks good! Thanks @emliunix! |
@erickguan I tested client_secret and in short, it works fine. Also I'd like to record my findings: How I obtain the refresh token
client_secret considerationMicrosoft classifies application into either Public Client or Confidential Client. And that's determined by the platform you choose in step 2 above And what it means is that:
|
Thanks a lot for this great notes! @emliunix Would you like to start a PR to enrich them in our onedrives' guide? See https://github.com/apache/opendal/blob/main/core/src/services/onedrive/docs.md |
Which issue does this PR close?
Closes #5653.
Part of #5677.
Part of #5702.
Rationale for this change
What changes are included in this PR?
This is a somewhat large PR. Reviewing it commit by commit is easier.
Are there any user-facing changes?
I added a few more refresh token settings for the OneDrive service. I added the documentation.