Auth0.swift icon indicating copy to clipboard operation
Auth0.swift copied to clipboard

Getting "No credentials were found in the store." on production app

Open Kaur-Pushpinder opened this issue 1 year ago • 7 comments

Checklist

  • [X] The issue can be reproduced in the Auth0.swift 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

This issue is randomly reproduced while renewing the token.

Reproduction

This issue is randomly reproduced while renewing the token. IMG_0958

Additional context

No response

Auth0.swift version

2.7.2

Platform

iOS

Platform version(s)

17+

Xcode version

15.3

Package manager

Cocoapods

Kaur-Pushpinder avatar Jul 09 '24 11:07 Kaur-Pushpinder

Hi @Kaur-Pushpinder,

Can you help us with the steps to reproduce ?

And is the issue #863 also opened by someone from your team ?

desusai7 avatar Jul 11 '24 05:07 desusai7

@desusai7 this is a random issue, there are no specific steps. just one info it is coming in renewAuth.

Kaur-Pushpinder avatar Jul 19 '24 06:07 Kaur-Pushpinder

@desusai7 any update on this?

Kaur-Pushpinder avatar Aug 19 '24 05:08 Kaur-Pushpinder

I am also experiencing similar issue, though I've been able to determine that in my case it breaks on NSKeyedUnarchiver

[path/ios.app]"
)}" UserInfo={NSDebugDescription=value for key 'root' was of unexpected class 'A0Credentials' (0x105529ff8) [/path/ios.app/Frameworks/Auth0.framework].
Allowed classes are:
 {(
    "'A0Credentials' (0x101562e50) [path/ios.app]"
)}}

Is there any particular reason why NSKeyedUnarchiver is used instead of Swift's JSONDecoder?

Vaidios avatar Sep 05 '24 12:09 Vaidios

@desusai7 Could you let us know if this is something your team is aware of an looking into?

theolampert avatar Sep 10 '24 07:09 theolampert

Hi @theolampert, @Vaidios,

Thank you for sharing more details on the issue and raising a PR to address this, we will look into it and get back to you !

desusai7 avatar Sep 10 '24 07:09 desusai7

@desusai7 Thanks!

theolampert avatar Sep 10 '24 07:09 theolampert

@desusai7 As an interum solution would you accept a PR that made the credentialManager's decoding method throwing so that those of who've noticed this could try to eliminate the cause and gather more info?

This would be a breaking change.

theolampert avatar Nov 06 '24 15:11 theolampert

Hi @Vaidios,

In your case, there seem to be two A0Credentials classes, one in the Auth0 framework and one in your app bundle. Screenshot 2025-01-10 at 13 34 57

Widcket avatar Jan 10 '25 16:01 Widcket

Hi @theolampert,

You can create a custom storage type conforming to CredentialsStorage that proxies to SimpleKeychain, and use it to log any Keychain errors.

E.g.

let credentialsManager = CredentialsManager(authentication: authentication, 
                                            storage: ProxyStore())

You can see how Auth0.swift uses SimpleKeychain here: https://github.com/auth0/Auth0.swift/blob/master/Auth0/CredentialsStorage.swift#L30 Specifically, you'd need to catch the error here instead of using try?.

That is because Auth0.swift v2.0.0 came out before SimpleKeychain v1.0.0 (in which the decoding method became throwing), and thus, this solution was needed to avoid a breaking change in Auth0.swift.

Widcket avatar Jan 10 '25 16:01 Widcket

Hi @Kaur-Pushpinder,

You can use the method suggested above ☝🏼 to log the underlying Keychain error.

Widcket avatar Jan 10 '25 16:01 Widcket

Please report back what the underlying Keychain error was if you're still experiencing this issue.

Widcket avatar Jan 10 '25 16:01 Widcket

Hi @theolampert,

You can create a custom storage type conforming to CredentialsStorage that proxies to SimpleKeychain, and use it to log any Keychain errors.

E.g.

let credentialsManager = CredentialsManager(authentication: authentication, 
                                            storage: ProxyStore())

You can see how Auth0.swift uses SimpleKeychain here: https://github.com/auth0/Auth0.swift/blob/master/Auth0/CredentialsStorage.swift#L30 Specifically, you'd need to catch the error here instead of using try?.

That is because Auth0.swift v2.0.0 came out before SimpleKeychain v1.0.0 (in which the decoding method became throwing), and thus, this solution was needed to avoid a breaking change in Auth0.swift.

Thanks for the reply, I'll take a look at doing that and report back anything.

theolampert avatar Jan 10 '25 17:01 theolampert