Skip to content

Commit 6570b6d

Browse files
Save id_token in Apple provider
If SaveTokens is set to true, save the id_token in the Apple provider like the SuperOffice provider does. Addresses #556.
1 parent fcbd67a commit 6570b6d

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/AspNet.Security.OAuth.Apple/AppleAuthenticationHandler.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,13 @@ private async Task<HandleRequestResult> HandleRemoteAuthenticateAsync(
339339
}
340340
}
341341

342+
string? idToken = tokens.Response.RootElement.GetString("id_token");
343+
344+
if (!string.IsNullOrEmpty(idToken))
345+
{
346+
authTokens.Add(new AuthenticationToken() { Name = "id_token", Value = idToken });
347+
}
348+
342349
properties.StoreTokens(authTokens);
343350
}
344351

test/AspNet.Security.OAuth.Providers.Tests/Apple/AppleTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ protected internal override void RegisterAuthentication(AuthenticationBuilder bu
4545
{
4646
ConfigureDefaults(builder, options);
4747
options.ClientId = "com.martincostello.signinwithapple.test.client";
48+
options.SaveTokens = true;
4849
});
4950
}
5051

test/AspNet.Security.OAuth.Providers.Tests/SuperOffice/SuperOfficeTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ protected internal override void RegisterAuthentication(AuthenticationBuilder bu
3535
ConfigureDefaults(builder, options);
3636

3737
options.ClientId = "gg454918d75b1b53101065c16ee51123";
38+
options.SaveTokens = true;
3839
options.TokenValidationParameters.ValidAudience = options.ClientId;
3940
options.TokenValidationParameters.ValidIssuer = "https://sod.superoffice.com";
4041
});

0 commit comments

Comments
 (0)