Apple Sign In for iOS 13 and above

This question is moreover related to Apple Sign and to get access_token and refresh_token at the end of authorization on iOS 13 and above.


I am developing a Sign In with Apple feature in Xamarin.Forms. I got sample code from here.


For iOS 13:

  • I used ASAuthorizationAppleIdButton, ASAuthorizationAppleIdProvider, ASAuthorizationAppleIdCredential etc to get id_token and authorization code.
  • When I try to call validate token as mentioned over here using my API support, apple throws 400 invalid_request (uses more than one mechanism for authenticating the client) I just wanted to know, how to get access_token, refresh_token in 2nd step for iOS 13 and above.


For non-iOS 13 (below iOS 13 and Android)

  • We have implemented authorize and validate token endpoints on Api side with a callback URL
  • I call my API endpoint in browser which ultimately calls apple authorize endpoint, once user completes the process, apple calls back redirect URL and returns code and state, at this point we exchange token (validate token) by calling apple given validate token endpoint and passing received authorization_code and state in the the request. At this step I receive access_token and refresh_token as mentioned here.


I just wanted to know how to get access_token and refresh_token for iOS 13 like we are able to do it for non-iOS 13 platforms.

Is ther any example or documentation available on getting access_token and refresh_token for iOS 13 and above or Is there any specific way to get these tokens on iOS 13?


Update:

My API reuqest looks like this:

public virtual Uri GenerateAuthorizationUrl()
{
  var respType = "code";

  var p = new Dictionary<string, string="">
  {
  { "response_type", respType },
  { "response_mode", "form_post" },
  { "client_id", ServerId },
  { "redirect_uri", RedirectUri.OriginalString },
  { "nonce", Nonce },
  { "state", State },
  { "scope", "name email" }
  };
}

public async Task ExchangeTokenAsync(string code)
{
  var secret = GenerateClientSecretJWT(P8FileContents);

  var resp = await client.PostAsync(AppleTokenUrl, new FormUrlEncodedContent(new Dictionary<string, string="">
  {
  { "grant_type", "authorization_code" },
  { "code", code },
  { "redirect_uri", RedirectUri.OriginalString },
  { "client_id", ServerId },
  { "client_secret", secret },
  }));

  resp.EnsureSuccessStatusCode();
}


Thanking you in advance.

Apple Sign In for iOS 13 and above
 
 
Q