private static async Task AuthorizeAndSaveTokenAsync() { // Create the TwinfieldApi var twinfieldApi = new TwinfieldApi(oauthClientSettings); // First get the authorization URL Console.WriteLine("Send the user to the following URL:"); Console.WriteLine(twinfieldApi.GetAuthorizationUrl(redirectUrl)); // Catch the authorization code in your own program, and paste it here Console.Write("\n\nEnter the code: "); var authenticationCode = Console.ReadLine(); // Get the access token await twinfieldApi .SetAccessTokenByAuthorizationCodeAsync(authenticationCode, redirectUrl); // Store the access token in KeyVault var accessToken = twinfieldApi.Token; Console.WriteLine("Saving access token to KeyVault.."); await StoreAccesstokenInKeyVaultAsync(accessToken); Console.WriteLine("Done."); }
/// <summary> /// Authorization flow. /// </summary> static async Task Example1() { // First get the authorization URL Console.WriteLine("Send the user to the following URL:"); Console.WriteLine(twinfieldApi.GetAuthorizationUrl(redirectUrl)); // Catch the authorization code in your own program, and paste it here Console.Write("\n\nEnter the code: "); var authenticationCode = Console.ReadLine(); // Get the access token await twinfieldApi .SetAccessTokenByAuthorizationCodeAsync(authenticationCode, redirectUrl); accessToken = twinfieldApi.Token; }