auth0-flutter icon indicating copy to clipboard operation
auth0-flutter copied to clipboard

iOS: Configuring the associated domain does not work for custom domains

Open jlin5 opened this issue 1 year ago • 8 comments

Checklist

  • [X] The issue can be reproduced in the auth0_flutter sample app (or N/A).
  • [X] I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
  • [X] I have looked into the API documentation and have not found a suitable solution or answer.
  • [X] I have searched the issues and have not found a suitable solution or answer.
  • [X] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • [X] I agree to the terms within the Auth0 Code of Conduct.

Description

I followed the instructions in the README.md for iOS/macOS: Configure the associated domain and I was able to get the login and logout functions that use the useHTTPS: true property to work with the auth0 domain but not a custom domain.

I get this error when using the custom domain: An unexpected error occurred. CAUSE: Error Domain=com.apple.AuthenticationServices.WebAuthenticationSession Code=1 "Application with identifier {YOUR_BUNDLE_ID} is not associated with domain {YOUR_CUSTOM_DOMAIN}. Using HTTPS callbacks requires Associated Domains using the 'webcredentials' service type for {YOUR_CUSTOM_DOMAIN}." UserInfo={NSLocalizedFailureReason=Application with identifier {YOUR_BUNDLE_ID} is not associated with domain {YOUR_CUSTOM_DOMAIN}. Using HTTPS callbacks requires Associated Domains using the 'webcredentials' service type for {YOUR_CUSTOM_DOMAIN}.}

Reproduction

Follow the instructions in the README.md for iOS/macOS: Configure the associated domain and use a custom domain instead of the auth0 domain. Make sure the Auth0 SDK is initialized with the custom domain.

webcredentials:YOUR_CUSTOM_DOMAIN

Use the login and logout functions to see the error.

final credentials = await auth0.webAuthentication().login(useHTTPS: true);

await auth0.webAuthentication().logout(useHTTPS: true);

I ran the application on an iOS simulator version iOS 17.4+.

Additional context

No response

auth0_flutter version

1.6.0

Flutter version

3.19.3

Platform

iOS

Platform version(s)

No response

jlin5 avatar Apr 02 '24 21:04 jlin5

I am also facing the same issue, Any updates? @Widcket

Gaurav-CareMonitor avatar Apr 10 '24 07:04 Gaurav-CareMonitor

Just use old version of auth0_flutter I face same issue when I used 1.6.0 after downgrade to auth0_flutter : 1.3.0 my issue solved

  • add auth0_flutter : 1.3.0 to your dependinces
  • also add dependency overrides like that dependency_overrides: auth0_flutter: 1.3.0

enahmad96 avatar Apr 27 '24 15:04 enahmad96

I am having this same issue using the latest version of the Auth0 Swift SDK. Associated Domain does not work with the default Auth0 tenant domain or with a custom domain. Same steps to reproduce as OP, same error as OP. Any word on a fix @Widcket ? I will look into downgrading versions but I don't love that as a long term solution

tbmills1 avatar May 23 '24 19:05 tbmills1

This most likely means you ran the app before completing the SDK integration steps (before fulfilling all the requirements for the associated domain), and now Apple's CDN will have the wrong AASA file cached.

You can check by making a get request to https://app-site-association.cdn-apple.com/a/v1/YOUR_AUTH0_DOMAIN_OR_CUSTOM_DOMAIN. Check the headers for the expiry time, and either try again after it expires, or use an alternate mode as described here: https://developer.apple.com/documentation/xcode/supporting-associated-domains#Add-the-associated-domains-entitlement-to-your-app

Widcket avatar May 23 '24 19:05 Widcket

Note that for debugging purposes, you can attach any query parameter to the CDN URL, and it will cause the CDN to bypass the cached version and fetch the current AASA file (but it will not be persisted). E.g. https://app-site-association.cdn-apple.com/a/v1/YOUR_AUTH0_DOMAIN_OR_CUSTOM_DOMAIN?foo

Widcket avatar May 23 '24 20:05 Widcket

@Widcket I checked the AASA file and it looked correct to me. The only curious thing was that the applinks object was populated as well as the webcredentials object, but I am only using the webcredentials for associated domain in Xcode. I also tried downgrading versions as suggested for the flutter SDK earlier in this thread with no luck.

I am going to start from the beginning on a different Auth0 tenant and post the results. I will also try setting up a custom url scheme instead of the default to see if that works

tbmills1 avatar May 24 '24 15:05 tbmills1

This sounds like a bug with auth0 SDK. It started working for me after I added both the custom domain and the auth0 domain in the App.entitlements file.

webcredentials:{custom_domain}
webcredentials:{yourapp}_auth0.com

freesuraj avatar Jun 11 '24 09:06 freesuraj

I agree with @freesuraj. It worked for me if I used the Auth0 domain in the Auth0 initialization and in the .entitlements file instead of a custom domain.

@Widcket It looks like Auth0 only added the apple-app-site-association file for the Auth0 domain. When I tried https://app-site-association.cdn-apple.com/a/v1/CUSTOM_DOMAIN I get a Not Found status, but the file is there for https://app-site-association.cdn-apple.com/a/v1/YOUR_AUTH0_DOMAIN.

jlin5 avatar Jul 24 '24 14:07 jlin5