@@ -18,6 +18,7 @@ public partial class Startup
1818 public static string AppKey = String . Empty ;
1919 public static string TodoListResourceId = String . Empty ;
2020 public static string TodoListBaseAddress = String . Empty ;
21+ public static string GraphResourceId = String . Empty ;
2122
2223 public void ConfigureAuth ( IApplicationBuilder app )
2324 {
@@ -27,6 +28,7 @@ public void ConfigureAuth(IApplicationBuilder app)
2728 AppKey = Configuration . Get ( "AzureAd:AppKey" ) ;
2829 TodoListResourceId = Configuration . Get ( "AzureAd:TodoListResourceId" ) ;
2930 TodoListBaseAddress = Configuration . Get ( "AzureAd:TodoListBaseAddress" ) ;
31+ GraphResourceId = Configuration . Get ( "AzureAd:GraphResourceId" ) ;
3032
3133 // Configure the Session Middleware, Used for Storing Tokens
3234 app . UseSession ( ) ;
@@ -47,13 +49,12 @@ public void ConfigureAuth(IApplicationBuilder app)
4749
4850 public async Task OnAuthorizationCodeReceived ( AuthorizationCodeReceivedNotification notification )
4951 {
50- // Acquire a Token for the TodoList Web API, and Cache it For Later Use
52+ // Acquire a Token for the Graph API and cache it. In the TodoListController, we'll use the cache to acquire a token to the Todo List API
5153 string userObjectId = notification . AuthenticationTicket . Principal . FindFirst ( "http://schemas.microsoft.com/identity/claims/objectidentifier" ) . Value ;
5254 ClientCredential clientCred = new ClientCredential ( ClientId , AppKey ) ;
5355 AuthenticationContext authContext = new AuthenticationContext ( Authority , new NaiveSessionCache ( userObjectId , notification . HttpContext . Session ) ) ;
5456 AuthenticationResult authResult = await authContext . AcquireTokenByAuthorizationCodeAsync (
55- notification . Code , new Uri ( notification . RedirectUri ) , clientCred , Startup . TodoListResourceId ) ;
56-
57+ notification . Code , new Uri ( notification . RedirectUri ) , clientCred , Startup . GraphResourceId ) ;
5758 }
5859 }
5960}
0 commit comments