-
Notifications
You must be signed in to change notification settings - Fork 36
Add R API for Custom OAuth Integrations (and add support getDelegatedAzureToken in VSCode and Positron sessions) #322
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
base: main
Are you sure you want to change the base?
Conversation
- Added `getOAuthIntegrations` and `getOAuthIntegration` functions for managing OAuth integrations in Posit Workbench. - Updated `getOAuthCredentials` function to use audience GUID instead of integration ID. - Enhanced error handling for OAuth functionality checks. - Updated DESCRIPTION and NAMESPACE files to include new imports and exports. - Added corresponding documentation files for new functions. - Expanded test coverage for OAuth integration functionalities.
Change type parameter default from c('r', 'rmarkdown', 'sql') to 'r'
and explicitly specify choices in match.arg() call. This resolves
R CMD check warning about codoc mismatch between code and docs.
The 'getOAuthCredentials allows dev versions' test was expecting a specific error message 'HTTP request failed', but the error message varies across different environments (could be 'Could not resolve host', 'Failed to connect', etc.). Changed to just expect any error, since the test's purpose is to verify that dev versions skip the version check, not to test the exact HTTP 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.
Pull request overview
This PR adds R API support for OAuth integrations in Posit Workbench and extends Azure token functionality to work in VSCode and Positron. The main additions enable R users to authenticate with external services through Workbench's OAuth infrastructure and retrieve delegated Azure tokens in non-RStudio IDEs.
Key changes:
- Added four new OAuth-related functions:
getOAuthIntegrations(),findOAuthIntegration(),getOAuthIntegration(), andgetOAuthCredentials() - Enhanced
getDelegatedAzureToken()to fall back to RPC endpoints when RStudio API is unavailable - Added comprehensive error handling for version checks, session validation, and OAuth2 errors
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| R/auth.R | Core implementation of OAuth API functions and internal helpers for RPC calls, session checks, and version validation |
| tests/testthat/test-oauth.R | Unit tests covering error conditions, environment variable handling, and parameter validation |
| DESCRIPTION | Added httr and jsonlite as Suggests dependencies for HTTP/JSON functionality |
| NAMESPACE | Exported four new OAuth-related functions |
| man/getOAuthIntegrations.Rd | Documentation for retrieving all OAuth integrations |
| man/findOAuthIntegration.Rd | Documentation for searching OAuth integrations by criteria |
| man/getOAuthIntegration.Rd | Documentation for retrieving a specific integration by GUID |
| man/getOAuthCredentials.Rd | Documentation for retrieving OAuth credentials |
| man/getDelegatedAzureToken.Rd | Updated documentation with return value description |
| man/rstudio-documents.Rd | Updated documentation for documentNew type parameter |
| R/document-api.R | Modified documentNew to use explicit choices parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove unecessary return() - Rename check -> assert - Remove unecessary `.` for internal funcs - Augment credential response
Co-authored-by: Aaron Jacobs <[email protected]>
|
I'm fine with this so long as Kevin (as the actual maintainer) doesn't have major issues. |
kevinushey
left a comment
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.
Overall LGTM, but I think we want to avoid the auto-unboxing behavior and instead explicitly indicate whether we desire unboxing for specific elements of the values we're POSTing.
Summary
Resolves rstudio/rstudio-pro#
This PR adds comprehensive R API support for custom OAuth integrations in Posit Workbench, enabling users to authenticate with external services through Workbench's OAuth infrastructure. It also enhances
getDelegatedAzureToken()to work in non-RStudio IDEs (VSCode, Positron).Usage Examples
Implementation Details
X-RS-Session-Server-RPC-CookieheaderREQUESTS_CA_BUNDLEandCURL_CA_BUNDLEenvironment variablesTesting