Repository navigation
Add support for interactive Entra ID authentication to chat_azure() - #273
Merged
Merged
Conversation
hadley
approved these changes
Jan 25, 2025
| roles: {.emph Cognitive Services OpenAI User}, | ||
| {.emph Cognitive Services OpenAI Contributor}, or | ||
| {.emph Cognitive Services Contributor}.", | ||
| keep_whitespace = FALSE |
Member
There was a problem hiding this comment.
Do you need that? I think it will get re-wrapped anyway?
Collaborator
Author
There was a problem hiding this comment.
In my testing it doesn't get re-wrapped without this 😭.
atheriel
force-pushed
the
azure-cli-auth
branch
from
January 27, 2025 16:32
001b513 to
63f259b
Compare
This commit adds support for another major Azure authentication
approach: the OAuth authorization code flow, as used by the Azure CLI.
This is a good choice for authentiation during development on desktop,
and Microsoft recommends it for Azure OpenAI because it doesn't require
storing sensitive long-lived secrets like API keys.
All of this is pretty stock httr2 OAuth stuff, despite the fact that
Entra ID has its own... idiosyncrasies. I also went out of the way to
add a really specific error message for what I believe to be a common
source of problems: misconfiguration of Azure's RBAC. It looks as
follows:
Error in `req_perform_connection()` at elmer/R/httr2.R:36:3:
! HTTP 401 Unauthorized.
• PermissionDenied: Principal does not have access to API/Operation.
ℹ Your user or service principal likely needs one of the following
roles: Cognitive Services OpenAI User, Cognitive Services OpenAI
Contributor, or Cognitive Services Contributor.
I haven't added any unit tests (I don't know how to do so for this kind
of interactive OAuth flow), but at least the help documentation has been
updated.
Signed-off-by: Aaron Jacobs <aaron.jacobs@posit.co>
atheriel
force-pushed
the
azure-cli-auth
branch
from
January 27, 2025 16:35
63f259b to
6fc0b4b
Compare
Collaborator
Author
|
Got a real Entra ID RBAC setup working with this today, so I consider it good to go. |
Member
|
Feel free to merge once the CI checks pass. |
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.
This commit adds support for another major Azure authentication approach: the OAuth authorization code flow, as used by the Azure CLI.
This is a good choice for authentiation during development on desktop, and Microsoft recommends it for Azure OpenAI because it doesn't require storing sensitive long-lived secrets like API keys.
All of this is pretty stock httr2 OAuth stuff, despite the fact that Entra ID has its own... idiosyncrasies. I also went out of the way to add a really specific error message for what I believe to be a common source of problems: misconfiguration of Azure's RBAC. It looks as follows:
I haven't added any unit tests (I don't know how to do so for this kind of interactive OAuth flow), but at least the help documentation has been updated.