新的Apple ID登录无效授予问题

问题描述 投票:6回答:1

到目前为止,我一直遵循this post,它对我有很大帮助,但是,我现在得到了“ invalid_grant”。以下:https://developer.apple.com/documentation/signinwithapplerestapi/errorresponse我了解由于授权授予或刷新令牌无效,我遇到了问题。

尽管进行了搜索和尝试(和重试),但我仍然受困,并且我不知道它来自哪里。我使用了https://developer.apple.com/documentation/authenticationservices/adding_the_sign_in_with_apple_flow_to_your_app

上给出的应用

现在我从上面的应用程序中获取了令牌,我尝试从C#后端对其进行验证,但得到400响应代码invalid_grant

我从帖子中注意到的唯一区别是,与下图相比,我没有来自门户的任何[Verify]按钮(选项)或[Download]按钮。我不知道这是否相关,但我正在尝试提供尽可能多的详细信息:

enter image description here


希望有人可以提供帮助,谢谢您的帮助:)如果需要,随时询问更多详细信息

最大

ios oauth signing apple-id
1个回答
1
投票

您能否分享您尝试创建JWT的方式?我已经正确地尝试了几件事,我知道(这也不起作用,如果找到真正的解决方案,会更新)

const string iss = "7#######G"; //  team ID 
            const string aud = "https://appleid.apple.com";
            const string sub = "com.######.weblogin"; // serviceid
            const string privateKey = "MIGTA#######"; // contents of .p8 file     

            var d = DateTime.UtcNow.AddDays(-5);

            var cngKey = CngKey.Import(
              Convert.FromBase64String(privateKey),
              CngKeyBlobFormat.Pkcs8PrivateBlob);


            var handler = new JwtSecurityTokenHandler();


            var securityKey = new ECDsaSecurityKey(new ECDsaCng(cngKey) { KeySize = 256 , HashAlgorithm = CngAlgorithm.ECDsaP256});


            securityKey.KeyId = "G#######W";
            var signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.EcdsaSha256);

            return  handler.CreateEncodedJwt(iss, aud, new ClaimsIdentity(new List<Claim> { new Claim("sub", sub) }),d, expires: d.AddMonths(3),d, signingCredentials: signingCredentials);

头文件在jwt中看起来像这样,从我收集到的内容来看,可能有很多情况下都不存在的“ typ”头文件,也许我应该摆脱它:

{
  "alg": "ES256",
  "kid": "G#######W",
  "typ": "JWT"
}

正文:

{
  "sub": "com.#####.weblogin",
  "nbf": 1583088895,
  "exp": 1591037695,
  "iat": 1583088895,
  "iss": "7######G",//teamid
  "aud": "https://appleid.apple.com"
}
© www.soinside.com 2019 - 2024. All rights reserved.