# Swift SecureCredentialsManager token persistence

**URL:** <https://community.auth0.com/t/swift-securecredentialsmanager-token-persistence/99673>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, auth0-swift\
**Created:** [February 3, 2023, 4:31pm UTC](https://community.auth0.com/t/swift-securecredentialsmanager-token-persistence/99673 "2023-02-03T16:31:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryan.kramer](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ryan.kramer](https://community.auth0.com/u/ryan.kramer)\
**Post date:** [February 3, 2023, 4:31pm UTC](https://community.auth0.com/t/swift-securecredentialsmanager-token-persistence/99673/1 "2023-02-03T16:31:59Z")

</div>

Hello, we are seeing that an auth token, refresh-tokens saved with SecureCredentialsManager seem to be lost or expired once the device is turned off. To me it would seem they should be persisted through this case but maybe this is intentional behavior. Would appreciate is someone could confirm which is the case. Thank you.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [February 3, 2023, 10:54pm UTC](https://community.auth0.com/t/swift-securecredentialsmanager-token-persistence/99673/3 "2023-02-03T22:54:23Z")

</div>

Hey there @ryan.kramer welcome to the community!

Tokens stored using [CredentialsManager](https://github.com/auth0/Auth0.swift/blob/master/EXAMPLES.md#credentials-manager-ios--macos--tvos--watchos) and subsequently the devices keychain should persist when the device is turned off/restarted. Are you receiving any errors when you go to retrieve stored credentials on restart? [Refresh tokens](https://auth0.com/docs/secure/tokens/refresh-tokens/configure-refresh-token-expiration) are typically long lived so I doubt ( depending on how long the device is turned off for) it is expired in this scenario.

The more information you can provide about your environment, use case, steps to reproduce, etc. the better. Keep us posted!

---

<div class="post-metadata">

**Author:** ![ryan.kramer](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ryan.kramer](https://community.auth0.com/u/ryan.kramer)\
**Post date:** [February 6, 2023, 2:22pm UTC](https://community.auth0.com/t/swift-securecredentialsmanager-token-persistence/99673/4 "2023-02-06T14:22:10Z")

</div>

Thanks for the response. I just wanted to confirm that the behavior we are experiencing is not the intended behavior. I will do some more investigation/debugging to see what error codes I may be getting. Will report back with anything specific. Thanks you.

---

<div class="post-metadata">

**Author:** ![ryan.kramer](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ryan.kramer](https://community.auth0.com/u/ryan.kramer)\
**Post date:** [February 6, 2023, 4:41pm UTC](https://community.auth0.com/t/swift-securecredentialsmanager-token-persistence/99673/5 "2023-02-06T16:41:45Z")

</div>

I think this issue was due to an error while testing. Seems the token is not expiring on device being turned off which is expected.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [February 6, 2023, 4:45pm UTC](https://community.auth0.com/t/swift-securecredentialsmanager-token-persistence/99673/6 "2023-02-06T16:45:37Z")

</div>

Hey @ryan.kramer - Great, good to know things are functioning as expected! Thanks for confirming here 😄

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 20, 2023, 4:46pm UTC](https://community.auth0.com/t/swift-securecredentialsmanager-token-persistence/99673/7 "2023-02-20T16:46:02Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
