add 'as' parameter to getDelegatedAzureToken()#328
Open
kevinushey wants to merge 1 commit into
Open
Conversation
With as = "AzureToken", the token is wrapped in an R6 object compatible with the AzureToken class from the AzureAuth package, so it can be passed directly to packages like AzureGraph and Microsoft365R. The object's refresh() method requests a new delegated token from Workbench. Also normalizes the token shape across IDEs: the direct Workbench RPC path now converts the relative 'expires_in' to an absolute 'expires_at', matching what RStudio sessions already returned. Addresses rstudio/rstudio#17619.
zachhannum
approved these changes
Jun 11, 2026
zachhannum
left a comment
Contributor
There was a problem hiding this comment.
This is awesome, LGTM! I think we should update the example(s) in our docs once this lands: https://docs.posit.co/ide/server-pro/user/posit-workbench/managed-credentials/azure.html#microsoft-graph-api
The current Graph example chickens out and just calls the API directly 😆
@zachhannum FYI I made a draft PR here for the doc update: https://github.com/rstudio/rstudio-pro/pull/11390 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Addresses rstudio/rstudio#17619.
Summary
getDelegatedAzureToken()gains anas = c("list", "AzureToken")parameter. The default ("list") is unchanged. Withas = "AzureToken", the token is wrapped in an R6 object compatible with theAzureTokenclass from the AzureAuth package, so it can be passed directly to packages like AzureGraph and Microsoft365R:Design notes
AzureToken, so it passesAzureAuth::is_azure_token()without requiring AzureAuth to be installed. Only R6 is needed (added to Suggests), and only for theas = "AzureToken"path.credentials(withtoken_type,access_token, andexpires_on),version = 1withresourceset (soAzureGraph::find_resource_host()can parse the host), plusvalidate(),can_refresh(),refresh(),hash(),cache(), andprint().refresh()simply re-callsgetDelegatedAzureToken(): Workbench owns the OIDC refresh token and performs a fresh token refresh server-side on every request, so auto-refresh in long-running AzureGraph sessions works without exposing any client credentials to the session.expires_in, while RStudio sessions returned an absoluteexpires_at. Both paths now returnexpires_at.The diff includes cosmetic regeneration of unrelated
man/*.Rdfiles from the roxygen2 8.0.0 update picked up bydevtools::document().Testing
asvalidation,expires_innormalization, the AzureToken interface surface, expiry validation, and refresh (vialocal_mocked_bindings).