Skip to content

Add ability to set auth scopes via request options#23

Merged
rickykaare merged 2 commits intomainfrom
request-scopes
Jun 10, 2025
Merged

Add ability to set auth scopes via request options#23
rickykaare merged 2 commits intomainfrom
request-scopes

Conversation

@rickykaare
Copy link
Contributor

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for multiple authentication scopes via request options

  • Converts GetScope APIs to GetScopes returning string[] and updates generator, handler, builder, and sample code accordingly
  • Introduces HttpRequestMessageExtensions to set/get per-request scopes
  • Updates all related tests to pass and verify scope arrays instead of single TokenRequestContext

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/Cabazure.Client.Tests/ClientInitializationGeneratorTests.CanGenerate_Initialization#ClientInitialization.Implementation.g.verified.cs Update generator test to use GetScopes and pass scope array to handler
test/Cabazure.Client.Runtime.Tests/Builder/HttpClientBuilderExtensionsTests.cs Rename test to use scopes and replace TokenRequestContext with string[]
test/Cabazure.Client.Runtime.Tests/Authentication/BearerTokenProviderTests.cs Update tests to call GetTokenAsync(string[] scopes, token)
test/Cabazure.Client.Runtime.Tests/Authentication/AzureAuthenticationHandlerTests.cs Adjust handler test to expect GetTokenAsync(string[], CancellationToken)
src/Cabazure.Client/ClientInitializationGenerator.cs Replace GetScope/TokenRequestContext calls with GetScopes/string[]
src/Cabazure.Client.Runtime/ICabazureAuthClientOptions.cs Change GetScope() to GetScopes(): string[]
src/Cabazure.Client.Runtime/HttpRequestMessageExtensions.cs Add extensions to store and retrieve string[] scopes on HttpRequestMessage
src/Cabazure.Client.Runtime/Builder/HttpClientBuilderExtensions.cs Modify AddAuthentication overloads to accept scopes arrays
src/Cabazure.Client.Runtime/Authentication/IBearerTokenProvider.cs Update interface to GetTokenAsync(string[] scopes, CancellationToken)
src/Cabazure.Client.Runtime/Authentication/BearerTokenProvider.cs Implement per-scope caching and use string[] scopes for token requests
src/Cabazure.Client.Runtime/Authentication/AzureAuthenticationHandler.cs Read scopes from request or default and pass to GetTokenAsync
samples/AzureRest/AzureRest.Client/AzureRestClientOptions.cs Update sample to implement GetScopes() returning an array
Comments suppressed due to low confidence (2)

test/Cabazure.Client.Runtime.Tests/Builder/HttpClientBuilderExtensionsTests.cs:36

  • [nitpick] The parameter name context is misleading for a scopes array. Rename it to scopes to accurately reflect its purpose.
string[] context,

src/Cabazure.Client.Runtime/HttpRequestMessageExtensions.cs:1

  • This extension references HttpRequestMessage but is missing using System.Net.Http;, causing a compile error. Add the appropriate using directive.
namespace Cabazure.Client;

@rickykaare rickykaare merged commit 96e62e8 into main Jun 10, 2025
2 checks passed
@rickykaare rickykaare deleted the request-scopes branch June 10, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants