private static async Task AcquireTokenAsync() { TokenBroker app = new TokenBroker(); string token = await GetTokenIntegratedAuthAsync(app.Sts).ConfigureAwait(false); Console.WriteLine(token); }
public static async Task <AuthenticationResult> GetTokenSilentAsync(User user) { TokenBroker brkr = new TokenBroker(); PublicClientApplication app = new PublicClientApplication("269da09d-a3e8-4b9e-b0a3-18fdf67d7507"); try { return(await app.AcquireTokenSilentAsync(brkr.Sts.ValidScope)); } catch (Exception ex) { string msg = ex.Message + "\n" + ex.StackTrace; Console.WriteLine(msg); return(await app.AcquireTokenAsync(brkr.Sts.ValidScope, user.DisplayableId, UiOptions.ActAsCurrentUser, null)); } }
public static async Task <AuthenticationResult> GetTokenInteractiveAsync() { try { TokenBroker brkr = new TokenBroker(); PublicClientApplication app = new PublicClientApplication("269da09d-a3e8-4b9e-b0a3-18fdf67d7507"); await app.AcquireTokenAsync(brkr.Sts.ValidScope); return(await app.AcquireTokenAsync(brkr.Sts.ValidScope)); } catch (Exception ex) { string msg = ex.Message + "\n" + ex.StackTrace; Console.WriteLine(msg); } return(null); }