Skip to content

Commit f70a681

Browse files
authored
AuthenticationTokenProvider API feedback (Azure#50128)
1 parent e67f6b4 commit f70a681

File tree

8 files changed

+27
-27
lines changed

8 files changed

+27
-27
lines changed

sdk/core/Azure.Core.Experimental/api/Azure.Core.Experimental.net462.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ public abstract partial class AuthenticationTokenProvider
126126
{
127127
protected AuthenticationTokenProvider() { }
128128
public abstract System.ClientModel.Primitives.GetTokenOptions? CreateTokenOptions(System.Collections.Generic.IReadOnlyDictionary<string, object> properties);
129-
public abstract System.ClientModel.Primitives.AccessToken GetToken(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
130-
public abstract System.Threading.Tasks.ValueTask<System.ClientModel.Primitives.AccessToken> GetTokenAsync(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
129+
public abstract System.ClientModel.Primitives.AuthenticationToken GetToken(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
130+
public abstract System.Threading.Tasks.ValueTask<System.ClientModel.Primitives.AuthenticationToken> GetTokenAsync(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
131131
}
132132
}
133133
namespace System.ClientModel.Primitives
134134
{
135-
public partial class AccessToken
135+
public partial class AuthenticationToken
136136
{
137-
public AccessToken(string tokenValue, string tokenType, System.DateTimeOffset expiresOn, System.DateTimeOffset? refreshOn = default(System.DateTimeOffset?)) { }
137+
public AuthenticationToken(string tokenValue, string tokenType, System.DateTimeOffset expiresOn, System.DateTimeOffset? refreshOn = default(System.DateTimeOffset?)) { }
138138
public System.DateTimeOffset ExpiresOn { get { throw null; } }
139139
public System.DateTimeOffset? RefreshOn { get { throw null; } }
140140
public string TokenType { get { throw null; } }

sdk/core/Azure.Core.Experimental/api/Azure.Core.Experimental.net6.0.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ public abstract partial class AuthenticationTokenProvider
126126
{
127127
protected AuthenticationTokenProvider() { }
128128
public abstract System.ClientModel.Primitives.GetTokenOptions? CreateTokenOptions(System.Collections.Generic.IReadOnlyDictionary<string, object> properties);
129-
public abstract System.ClientModel.Primitives.AccessToken GetToken(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
130-
public abstract System.Threading.Tasks.ValueTask<System.ClientModel.Primitives.AccessToken> GetTokenAsync(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
129+
public abstract System.ClientModel.Primitives.AuthenticationToken GetToken(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
130+
public abstract System.Threading.Tasks.ValueTask<System.ClientModel.Primitives.AuthenticationToken> GetTokenAsync(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
131131
}
132132
}
133133
namespace System.ClientModel.Primitives
134134
{
135-
public partial class AccessToken
135+
public partial class AuthenticationToken
136136
{
137-
public AccessToken(string tokenValue, string tokenType, System.DateTimeOffset expiresOn, System.DateTimeOffset? refreshOn = default(System.DateTimeOffset?)) { }
137+
public AuthenticationToken(string tokenValue, string tokenType, System.DateTimeOffset expiresOn, System.DateTimeOffset? refreshOn = default(System.DateTimeOffset?)) { }
138138
public System.DateTimeOffset ExpiresOn { get { throw null; } }
139139
public System.DateTimeOffset? RefreshOn { get { throw null; } }
140140
public string TokenType { get { throw null; } }

sdk/core/Azure.Core.Experimental/api/Azure.Core.Experimental.net8.0.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ public abstract partial class AuthenticationTokenProvider
126126
{
127127
protected AuthenticationTokenProvider() { }
128128
public abstract System.ClientModel.Primitives.GetTokenOptions? CreateTokenOptions(System.Collections.Generic.IReadOnlyDictionary<string, object> properties);
129-
public abstract System.ClientModel.Primitives.AccessToken GetToken(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
130-
public abstract System.Threading.Tasks.ValueTask<System.ClientModel.Primitives.AccessToken> GetTokenAsync(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
129+
public abstract System.ClientModel.Primitives.AuthenticationToken GetToken(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
130+
public abstract System.Threading.Tasks.ValueTask<System.ClientModel.Primitives.AuthenticationToken> GetTokenAsync(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
131131
}
132132
}
133133
namespace System.ClientModel.Primitives
134134
{
135-
public partial class AccessToken
135+
public partial class AuthenticationToken
136136
{
137-
public AccessToken(string tokenValue, string tokenType, System.DateTimeOffset expiresOn, System.DateTimeOffset? refreshOn = default(System.DateTimeOffset?)) { }
137+
public AuthenticationToken(string tokenValue, string tokenType, System.DateTimeOffset expiresOn, System.DateTimeOffset? refreshOn = default(System.DateTimeOffset?)) { }
138138
public System.DateTimeOffset ExpiresOn { get { throw null; } }
139139
public System.DateTimeOffset? RefreshOn { get { throw null; } }
140140
public string TokenType { get { throw null; } }

sdk/core/Azure.Core.Experimental/api/Azure.Core.Experimental.netstandard2.0.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ public abstract partial class AuthenticationTokenProvider
126126
{
127127
protected AuthenticationTokenProvider() { }
128128
public abstract System.ClientModel.Primitives.GetTokenOptions? CreateTokenOptions(System.Collections.Generic.IReadOnlyDictionary<string, object> properties);
129-
public abstract System.ClientModel.Primitives.AccessToken GetToken(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
130-
public abstract System.Threading.Tasks.ValueTask<System.ClientModel.Primitives.AccessToken> GetTokenAsync(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
129+
public abstract System.ClientModel.Primitives.AuthenticationToken GetToken(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
130+
public abstract System.Threading.Tasks.ValueTask<System.ClientModel.Primitives.AuthenticationToken> GetTokenAsync(System.ClientModel.Primitives.GetTokenOptions properties, System.Threading.CancellationToken cancellationToken);
131131
}
132132
}
133133
namespace System.ClientModel.Primitives
134134
{
135-
public partial class AccessToken
135+
public partial class AuthenticationToken
136136
{
137-
public AccessToken(string tokenValue, string tokenType, System.DateTimeOffset expiresOn, System.DateTimeOffset? refreshOn = default(System.DateTimeOffset?)) { }
137+
public AuthenticationToken(string tokenValue, string tokenType, System.DateTimeOffset expiresOn, System.DateTimeOffset? refreshOn = default(System.DateTimeOffset?)) { }
138138
public System.DateTimeOffset ExpiresOn { get { throw null; } }
139139
public System.DateTimeOffset? RefreshOn { get { throw null; } }
140140
public string TokenType { get { throw null; } }

sdk/core/Azure.Core.Experimental/src/Auth/AccessToken.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ namespace System.ClientModel.Primitives;
1010
/// <summary>
1111
/// Represents an OAuth token and its metadata.
1212
/// </summary>
13-
public class AccessToken
13+
public class AuthenticationToken
1414
{
1515
/// <summary>
16-
/// Initializes a new instance of the <see cref="AccessToken"/> class.
16+
/// Initializes a new instance of the <see cref="AuthenticationToken"/> class.
1717
/// </summary>
1818
/// <param name="tokenValue">The access token value.</param>
1919
/// <param name="tokenType">The type of the access token (e.g., "Bearer").</param>
2020
/// <param name="expiresOn">The date and time when the token expires.</param>
2121
/// <param name="refreshOn">Optional. The date and time when the token should be refreshed. Default is null.</param>
2222
/// <exception cref="ArgumentException">Thrown when <paramref name="tokenValue"/> is null or empty.</exception>
23-
public AccessToken(string tokenValue, string tokenType, DateTimeOffset expiresOn, DateTimeOffset? refreshOn = null)
23+
public AuthenticationToken(string tokenValue, string tokenType, DateTimeOffset expiresOn, DateTimeOffset? refreshOn = null)
2424
{
2525
Argument.AssertNotNullOrEmpty(tokenValue, nameof(tokenValue));
2626

sdk/core/Azure.Core.Experimental/src/Auth/AuthenticationTokenProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public abstract class AuthenticationTokenProvider
2626
/// <param name="properties">The options used by the <see cref="AuthenticationTokenProvider"/> to make a token request.</param>
2727
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
2828
/// <returns></returns>
29-
public abstract AccessToken GetToken(GetTokenOptions properties, CancellationToken cancellationToken);
29+
public abstract AuthenticationToken GetToken(GetTokenOptions properties, CancellationToken cancellationToken);
3030

3131
/// <summary>
3232
/// Gets the token.
3333
/// </summary>
3434
/// <param name="properties">The options used by the <see cref="AuthenticationTokenProvider"/> to make a token request.</param>
3535
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
3636
/// <returns></returns>
37-
public abstract ValueTask<AccessToken> GetTokenAsync(GetTokenOptions properties, CancellationToken cancellationToken);
37+
public abstract ValueTask<AuthenticationToken> GetTokenAsync(GetTokenOptions properties, CancellationToken cancellationToken);
3838
}

sdk/core/Azure.Core.Experimental/src/Auth/OAuth2BearerTokenAuthenticationPolicy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList<Pipe
4242
{
4343
throw new InvalidOperationException("Bearer token authentication is not permitted for non TLS protected (https) endpoints.");
4444
}
45-
AccessToken token;
45+
AuthenticationToken token;
4646
if (message.TryGetProperty(typeof(GetTokenOptions), out var rawContext) && rawContext is GetTokenOptions scopesContext)
4747
{
4848
var context = _flowContext.WithAdditionalScopes(scopesContext.Scopes);

sdk/core/Azure.Core.Experimental/tests/Auth/TokenProviderTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ public ClientCredentialTokenProvider(string clientId, string clientSecret)
132132
_client = new HttpClient(mockHandler);
133133
}
134134

135-
public override AccessToken GetToken(GetTokenOptions properties, CancellationToken cancellationToken)
135+
public override AuthenticationToken GetToken(GetTokenOptions properties, CancellationToken cancellationToken)
136136
{
137137
return GetAccessTokenInternal(false, properties, cancellationToken).GetAwaiter().GetResult();
138138
}
139139

140-
public override async ValueTask<AccessToken> GetTokenAsync(GetTokenOptions properties, CancellationToken cancellationToken)
140+
public override async ValueTask<AuthenticationToken> GetTokenAsync(GetTokenOptions properties, CancellationToken cancellationToken)
141141
{
142142
return await GetAccessTokenInternal(true, properties, cancellationToken).ConfigureAwait(false);
143143
}
@@ -157,7 +157,7 @@ public override GetTokenOptions CreateTokenOptions(IReadOnlyDictionary<string, o
157157
return null;
158158
}
159159

160-
internal async ValueTask<AccessToken> GetAccessTokenInternal(bool async, GetTokenOptions properties, CancellationToken cancellationToken)
160+
internal async ValueTask<AuthenticationToken> GetAccessTokenInternal(bool async, GetTokenOptions properties, CancellationToken cancellationToken)
161161
{
162162
if (!properties.Properties.TryGetValue("tokenUrl", out var tokenUri) || tokenUri is not string tokenUriValue)
163163
{
@@ -199,11 +199,11 @@ await _client.SendAsync(request) :
199199
DateTimeOffset expiresOn = now.AddSeconds(expiresIn);
200200
DateTimeOffset refreshOn = now.AddSeconds(expiresIn * 0.85);
201201

202-
return new AccessToken(accessToken, tokenType, expiresOn, refreshOn);
202+
return new AuthenticationToken(accessToken, tokenType, expiresOn, refreshOn);
203203
}
204204
}
205205

206-
public class ClientCredentialToken : AccessToken
206+
public class ClientCredentialToken : AuthenticationToken
207207
{
208208
private AuthenticationTokenProvider _provider;
209209
private GetTokenOptions properties;

0 commit comments

Comments
 (0)