-
Notifications
You must be signed in to change notification settings - Fork 1k
Update Storage to track 2 SDK #413
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
Changes from 4 commits
de72e08
a936ba2
b00bb81
5db2521
1b0efd4
81d0547
13f4272
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,6 @@ | |
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Identity.Web; | ||
using Microsoft.Identity.Web.TokenCacheProviders.InMemory; | ||
using WebApp_OpenIDConnect_DotNet.Infrastructure; | ||
using WebApp_OpenIDConnect_DotNet.Services.Arm; | ||
using WebApp_OpenIDConnect_DotNet.Services.GraphOperations; | ||
using Microsoft.Extensions.Hosting; | ||
|
@@ -40,11 +38,10 @@ public void ConfigureServices(IServiceCollection services) | |
options.HandleSameSiteCookieCompatibility(); | ||
}); | ||
|
||
services.AddOptions(); | ||
|
||
services.AddMicrosoftIdentityWebAppAuthentication(Configuration) | ||
.EnableTokenAcquisitionToCallDownstreamApi( new string[] { Constants.ScopeUserRead }) | ||
.AddInMemoryTokenCaches(); | ||
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) | ||
.AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd")) | ||
.EnableTokenAcquisitionToCallDownstreamApi(null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the null should not be necessary. Is it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, removed. |
||
.AddInMemoryTokenCaches(); | ||
|
||
// Add APIs | ||
services.AddGraphService(Configuration); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Azure.Core; | ||
using Microsoft.Identity.Client; | ||
using Microsoft.Identity.Web; | ||
|
||
namespace WebApp_OpenIDConnect_DotNet | ||
{ | ||
public class TokenAcquisitionTokenCredential : TokenCredential | ||
{ | ||
readonly private ITokenAcquisition _tokenAcquisition; | ||
|
||
/// <summary> | ||
/// Constructor from an ITokenAcquisition service. | ||
/// </summary> | ||
/// <param name="tokenAcquisition">Token acquisition.</param> | ||
public TokenAcquisitionTokenCredential(ITokenAcquisition tokenAcquisition) | ||
{ | ||
_tokenAcquisition = tokenAcquisition; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken) | ||
{ | ||
AuthenticationResult result = _tokenAcquisition.GetAuthenticationResultForUserAsync(requestContext.Scopes) | ||
.GetAwaiter() | ||
.GetResult(); | ||
return new AccessToken(result.AccessToken, result.ExpiresOn); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken) | ||
{ | ||
AuthenticationResult result = await _tokenAcquisition.GetAuthenticationResultForUserAsync(requestContext.Scopes).ConfigureAwait(false); | ||
return new AccessToken(result.AccessToken, result.ExpiresOn); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@{ | ||
ViewData["Title"] = "Blob"; | ||
} | ||
|
||
<h2>@ViewData["Title"]</h2> | ||
<h3>@ViewData["Message"]</h3> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,9 @@ | |
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Azure.Storage.Blobs" Version="12.6.0" /> | ||
<PackageReference Include="Microsoft.Identity.Web" Version="0.4.0-preview" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you'll have a merge conflict here. Microsoft.Identity.Web is 1.0.0 now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to latest GA package. |
||
<PackageReference Include="Microsoft.Identity.Web.UI" Version="0.4.0-preview" /> | ||
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Uh oh!
There was an error while loading. Please reload this page.