/// <inheritdoc /> protected override async Task <OAuthTokenResponse> ExchangeCodeAsync([NotNull] OAuthCodeExchangeContext context) { if (Options.GenerateClientSecret) { var secretGenerationContext = new AppleGenerateClientSecretContext(Context, Scheme, Options); await Events.GenerateClientSecret(secretGenerationContext); } return(await base.ExchangeCodeAsync(context)); }
private static async Task GenerateTokenAsync( AppleAuthenticationOptions options, Func <AppleClientSecretGenerator, AppleGenerateClientSecretContext, Task> actAndAssert) { // Arrange var builder = new WebHostBuilder() .Configure((app) => app.UseAuthentication()) .ConfigureServices((services) => { services.AddAuthentication() .AddApple(); }); using var host = builder.Build(); var httpContext = new DefaultHttpContext(); var scheme = new AuthenticationScheme("Apple", "Apple", typeof(AppleAuthenticationHandler)); var context = new AppleGenerateClientSecretContext(httpContext, scheme, options); var generator = host.Services.GetRequiredService <AppleClientSecretGenerator>(); await actAndAssert(generator, context); }
/// <summary> /// Invoked whenever the client secret needs to be generated. /// </summary> /// <param name="context">Contains information about the current request.</param> /// <returns> /// A <see cref="Task"/> representing the completed operation. /// </returns> public virtual async Task GenerateClientSecret([NotNull] AppleGenerateClientSecretContext context) => await OnGenerateClientSecret(context);
/// <summary> /// Loads the client private key as an asynchronous operation. /// </summary> /// <param name="context">The context.</param> /// <returns> /// A <see cref="Task{TResult}"/> representing the asynchronous operation /// to get the raw bytes of the private key to use for Sign in with Apple. /// </returns> public abstract Task <byte[]> LoadPrivateKeyAsync(AppleGenerateClientSecretContext context);
/// <summary> /// Generates a client secret for Sign in with Apple as an asynchronous operation. /// </summary> /// <param name="context">The context.</param> /// <returns> /// A <see cref="Task{TResult}"/> representing the asynchronous operation /// to generate a client secret for Sign in with Apple. /// </returns> public abstract Task <string> GenerateAsync(AppleGenerateClientSecretContext context);