Skip to content

Instantly share code, notes, and snippets.

@DmitrySikorsky
Created December 23, 2022 20:13
Show Gist options
  • Save DmitrySikorsky/4bd2ea954cbdee5c87eb693ba15e8368 to your computer and use it in GitHub Desktop.
Save DmitrySikorsky/4bd2ea954cbdee5c87eb693ba15e8368 to your computer and use it in GitHub Desktop.
private async Task<string> GetEmailFromAppleCode(string appleCode)
{
string privateKey = System.IO.File.ReadAllText(Path.Combine(this.environment.ContentRootPath, "AuthKey_XXXXXXXXXX.p8"));
AppleAuthProvider provider = new AppleAuthProvider(
"com.your.app",
"XXXXXXXXXX",
"XXXXXXXXXX",
"https://auth.yourapp.com/callback", // I don't know why it must be here but it is not used
string.Empty
);
AuthorizationToken authorizationToken = await provider.GetAuthorizationToken(appleCode, privateKey);
JwtSecurityToken jwt = new JwtSecurityToken(authorizationToken.Token);
return jwt.Claims.First(c => c.Type == ClaimTypes.Email).Value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment