You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "erickguan (via GitHub)" <gi...@apache.org> on 2025/02/23 15:31:44 UTC

[I] Set up behavior tests for OneDrive [opendal]

erickguan opened a new issue, #5653:
URL: https://github.com/apache/opendal/issues/5653

   Hey, based on the review comment #5632, I add this issue for setting up behavior tests for OneDrive in the CI.
   
   This requires a bit admin work, mainly with [Microsoft Entra ID](https://learn.microsoft.com/en-us/graph/auth/auth-concepts).
   
   I investigated how-to but didn't go through the entire process. Some understanding comes from my prior experience, too. And the process can be a bit complicated.
   
   To start, we go for the app-only access. These steps should be:
   
   1. Register a dev Microsoft account.
   2. Navigate to Microsoft Entra admin center and login. Then we create an application for OpenDAL in CI to access the dev account files.
   3. Go to Applications - App registrations
   5. Enroll in the M365 Developer Program or sign up for Azure with the dev account from 1.
   6. Register an [application](https://learn.microsoft.com/en-us/graph/auth-register-app-v2)
      * Supported account types: "Accounts in any organizational directory and personal Microsoft accounts". This type should work for the CI purpose.
   7. Obtain `Application (client) ID` and `client secrets`.
   8. Configure Platform Settings, `desktop application` type should work. If not, we can revise.
   9. Now OAuth 2.0 flow. Read [here](https://learn.microsoft.com/en-us/graph/auth-v2-service).
   10. Now configure permissions for Microsoft Graph, go to the application's API permissions page
   11. Add a permission, select "Files.ReadWrite".
   12. Go to Microsoft Entra admin center and find the application (in "Applications").
   13. You should be able to find admin consent with a few clicks and navigations.
   14. Validate if you can get a token:
   
       // Line breaks are for legibility only.
   
       POST https://login.microsoftonline.com/common/oauth2/v2.0/token HTTP/1.1
       Host: login.microsoftonline.com
       Content-Type: application/x-www-form-urlencoded
       
       client_id=535fb089-9ff3-47b6-9bfb-4f1264799865
       &scope=https%3A%2F%2Fgraph.microsoft.com%2F.default
       &client_secret=qWgdYA....L1qKv5bPX
       &grant_type=client_credentials
   
   15. Store credentials to 1Password.
   
   The workflow should be somewhat straightforward:
   
   ```yaml
   
   name: onedrive
   description: 'Behavior test for OneDrive'
   
   runs:
     using: "composite"
     steps:
       - name: Setup
         uses: 1password/load-secrets-action@v1
         with:
           export-env: true
         env:
           OPENDAL_ONEDRIVE_ROOT: op://services/onedrive/root
           OPENDAL_ONEDRIVE_CLIENT_ID: op://services/onedrive/client_id
           OPENDAL_ONEDRIVE_CLIENT_SECRET: op://services/onedrive/client_secret
   
       - name: Get OneDrive access token
         run: |
           TOKEN=$(curl --location --request POST 'https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token' \
             --header 'Content-Type: application/x-www-form-urlencoded' \
             --data-urlencode 'client_id=535fb089-9ff3-47b6-9bfb-4f1264799865' \
             --data-urlencode 'scope=https://graph.microsoft.com/.default' \
             --data-urlencode 'client_secret=qWgdYA....L1qKv5bPX' \
             --data-urlencode 'grant_type=client_credentials' | jq ".access_token")
   
           echo "OPENDAL_ONEDRIVE_ACCESS_TOKEN=$TOKEN" >> "$GITHUB_ENV"
   ```
   
   # Open question
   
   What about supporting the auth and refresh token for OneDrive service?
   
   IMO, this can wait as the access token is enough to test. Authentication, once set up, is trivial.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Set up behavior tests for OneDrive [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #5653:
URL: https://github.com/apache/opendal/issues/5653#issuecomment-2692040452

   > What about supporting the auth and refresh token for OneDrive service?
   
   I think that's a good idea. Google Drive is tested in the same way. The access token might be too short for use in CI, requiring frequent updates.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Set up behavior tests for OneDrive [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo closed issue #5653: Set up behavior tests for OneDrive
URL: https://github.com/apache/opendal/issues/5653


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org