PassKeys & App Implementation

Hello all,

First post in the forums! I hope this question has not been answered already and I missed it. If it has, I apologize in advance.

I downloaded the Shiny demo code. I updated the AccountManager to use my domain. I placed the required file on my server in the .well-known folder. Here is my code. Note: I replaced example with my real domain.

{ "applinks": { "details": [ {
"appIDs": [ "CC8JC8QC9K.com.example.Shiny" ], }
]
},
"webcredentials": { "apps": [ "CC8JC8QC9K.com.example.Shiny" ] }
}

One thing I'm not clear on is what applinks are and if it is even needed for this service or not. In either case, I went ahead and included it.

I added webcredentials:example.com to the Associated domains section under Signing Capabilities for my target. Again, example is replaced with my domain. I also included applinks:example.com since I don't fully understand the importance of that just yet.

I have enabled Associated Domain for the app in my developer account and imported the AuthenticationServices framework into the project.

When I run the app I get the following errors.

2023-03-30 15:57:43.005597-0500 Shiny[64202:1563051] [Authorization] ASAuthorizationController credential request failed with error: Error Domain=com.apple.AuthenticationServices.AuthorizationError Code=1001 "(null)" 2023-03-30 15:57:43.007370-0500 Shiny[64202:1562730] Request canceled.

I also noticed this in the sample code.

// Fetch the challenge from the server. The challenge needs to be unique for each request.

let challenge = Data()

Am I supposed to be doing something on my server? If so, where? I'm just not grasping why an Apple service such as this even relies on the developer's server to begin with.

A couple of final things to mention just in case it is relevant.

  1. I have a wildcard domain.
  2. My site uses a www redirect.
  3. I do use https://

What am I missing? Any help would be greatly appreciated!

Accepted Reply

After days of messing with this, I figured it out just by luck. It was due to my www redirect. I corrected the issue using nginx to serve the file.

If anyone else is having this issue, here is what I did in my server block after the redirect from non www and non HTTP to www and HTTPS. This will serve the file regardless of the root domain redirection.

# Add this location block to serve apple-app-site-association file
location = /.well-known/apple-app-site-association {
    default_type application/json;
    alias /var/www/yourwebsite.com/public_html/.well-known/apple-app-site-association;
} 

Hope this helps others!

Replies

After days of messing with this, I figured it out just by luck. It was due to my www redirect. I corrected the issue using nginx to serve the file.

If anyone else is having this issue, here is what I did in my server block after the redirect from non www and non HTTP to www and HTTPS. This will serve the file regardless of the root domain redirection.

# Add this location block to serve apple-app-site-association file
location = /.well-known/apple-app-site-association {
    default_type application/json;
    alias /var/www/yourwebsite.com/public_html/.well-known/apple-app-site-association;
} 

Hope this helps others!