Created
December 23, 2022 20:13
-
-
Save DmitrySikorsky/4bd2ea954cbdee5c87eb693ba15e8368 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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