[GH-ISSUE #481] Storing OAuthSwiftCredential in UserDefaults #313

Closed
opened 2026-03-03 16:47:37 +03:00 by kerem · 4 comments
Owner

Originally created by @ghost on GitHub (Jul 15, 2018).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/481

So I'm using latest version of Xcode, Swift, and OAuthSwift with a custom PingFederate endpoint that implements OpenID Connect on top of OAuth2. This will generate refresh tokens in when using the returned credential in the success handler, so I would like to store this credential to create automatic login without having to sign in again.

To my knowledge, OAuthSwiftCredential is a Codable object, at least in newer versions of the framework which I have installed via CocoaPods. However, every time I try to store the credential from the success handler in the User Defaults I get a SIGABRT error. I would really appreciate some help.

Originally created by @ghost on GitHub (Jul 15, 2018). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/481 So I'm using latest version of Xcode, Swift, and OAuthSwift with a custom PingFederate endpoint that implements OpenID Connect on top of OAuth2. This will generate refresh tokens in when using the returned credential in the success handler, so I would like to store this credential to create automatic login without having to sign in again. To my knowledge, OAuthSwiftCredential is a Codable object, at least in newer versions of the framework which I have installed via CocoaPods. However, every time I try to store the credential from the success handler in the User Defaults I get a SIGABRT error. I would really appreciate some help.
kerem closed this issue 2026-03-03 16:47:38 +03:00
Author
Owner

@jrtibbetts commented on GitHub (Jul 25, 2018):

I posted a similar issue (https://github.com/OAuthSwift/OAuthSwift/issues/453) in May, and it was fixed, but no release has been issued yet that includes it, not even 1.2.2, which is the latest one that's posted. It's such a pain for me that I'm considering replacing OAuthSwift in my project with something else.

<!-- gh-comment-id:407898427 --> @jrtibbetts commented on GitHub (Jul 25, 2018): I posted a similar issue (https://github.com/OAuthSwift/OAuthSwift/issues/453) in May, and it was fixed, but no release has been issued yet that includes it, not even 1.2.2, which is the latest one that's posted. It's such a pain for me that I'm considering replacing OAuthSwift in my project with something else.
Author
Owner

@phimage commented on GitHub (Jul 25, 2018):

Closed because issue template has been removed
Then this is a storing problem and no code to store in description

Then not the same issue ...

<!-- gh-comment-id:407931712 --> @phimage commented on GitHub (Jul 25, 2018): Closed because issue template has been removed Then this is a storing problem and no code to store in description Then not the same issue ...
Author
Owner

@ghost commented on GitHub (Jul 26, 2018):

I wrote the issue template in a paragraph format. I ended up getting it to work by encoding it as JSON but I don't understand why I can't directly store the credential considering the fact that it extends the Codable class already.

<!-- gh-comment-id:408096405 --> @ghost commented on GitHub (Jul 26, 2018): I wrote the issue template in a paragraph format. I ended up getting it to work by encoding it as JSON but I don't understand why I can't directly store the credential considering the fact that it extends the Codable class already.
Author
Owner

@phimage commented on GitHub (Jul 26, 2018):

issue template is information that I ask to you when you create the issue
And you remove all the question, do not take time to respond, and you want some help...

then I ask for code

See Prephirences framework, user defaults do not accept any data type, object are converted, to Data for instance
So you need to encode it

<!-- gh-comment-id:408103737 --> @phimage commented on GitHub (Jul 26, 2018): issue template is information that I ask to you when you create the issue And you remove all the question, do not take time to respond, and you want some help... then I ask for code See Prephirences framework, user defaults do not accept any data type, object are converted, to Data for instance So you need to encode it
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#313
No description provided.