[GH-ISSUE #453] OAuthSwiftCredential can't be key-archived or -unarchived #296

Closed
opened 2026-03-03 16:47:28 +03:00 by kerem · 6 comments
Owner

Originally created by @jrtibbetts on GitHub (Apr 16, 2018).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/453

Description:

I'm trying to encode the OAuthSwiftCredential that I get when successfully authenticated so that I can store it in UserDefaults, then decode it to use for future sessions. (If this isn't the right way to avoid having to re-authenticate every time I run my app, please let me know!) I've tried using JSONEncoder and NSKeyedArchiver; however, the former doesn't work because there hasn't been an OAuthSwift release with the Codable version of that file, nor can I use the NSKeyedArchiver, because it dies with the following error:

Could not cast value of type '_NSZeroData' (0x10c079bf8) to 'NSMutableData' (0x10d0820e0).
2018-04-15 21:50:43.124514-0400 xctest[36373:2534923] Could not cast value of type '_NSZeroData' (0x10c079bf8) to 'NSMutableData' (0x10d0820e0).

Ideally, you would issue a new OAuthSwift version that includes the Codable credential, or figure out why the NSKeyedArchiver version doesn't work.

OAuth Provider (Twitter, Github, ..):

DIscogs.com is what I tested with, but I don't think that it matters.

OAuth Version:

  • Version 1
  • Version 2

OS (Please fill the version) :

  • iOS :
  • OSX :
  • TVOS :
  • WatchOS :

Installation method:

  • Carthage
  • CocoaPods
  • Manually

Library version:

  • head
  • v1.2 (Swift 4.0)
  • v1.0.0
  • v0.6
  • other: (1.2.1)

Xcode version:

  • 9.0 (Swift 4.0)

  • 9.0 (Swift 3.2)

  • 8.x (Swift 3.x)

  • 8.0 (Swift 2.3)

  • 7.3.1

  • other: (Please fill in the version you are using.)

  • objective c

Originally created by @jrtibbetts on GitHub (Apr 16, 2018). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/453 ### Description: I'm trying to encode the `OAuthSwiftCredential` that I get when successfully authenticated so that I can store it in `UserDefaults`, then decode it to use for future sessions. (If this isn't the right way to avoid having to re-authenticate every time I run my app, please let me know!) I've tried using `JSONEncoder` and `NSKeyedArchiver`; however, the former doesn't work because there hasn't been an `OAuthSwift` release with the `Codable` version of that file, nor can I use the `NSKeyedArchiver`, because it dies with the following error: ``` Could not cast value of type '_NSZeroData' (0x10c079bf8) to 'NSMutableData' (0x10d0820e0). 2018-04-15 21:50:43.124514-0400 xctest[36373:2534923] Could not cast value of type '_NSZeroData' (0x10c079bf8) to 'NSMutableData' (0x10d0820e0). ``` Ideally, you would issue a new OAuthSwift version that includes the `Codable` credential, or figure out why the `NSKeyedArchiver` version doesn't work. ### OAuth Provider (Twitter, Github, ..): DIscogs.com is what I tested with, but I don't think that it matters. ### OAuth Version: - [X] Version 1 - [X] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [X] Carthage - [ ] CocoaPods - [ ] Manually ### Library version: - [ ] head - [ ] v1.2 (Swift 4.0) - [ ] v1.0.0 - [ ] v0.6 - [X] other: (1.2.1) ### Xcode version: - [X] 9.0 (Swift 4.0) - [ ] 9.0 (Swift 3.2) - [ ] 8.x (Swift 3.x) - [ ] 8.0 (Swift 2.3) - [ ] 7.3.1 - [ ] other: (Please fill in the version you are using.) - [ ] objective c
kerem closed this issue 2026-03-03 16:47:29 +03:00
Author
Owner

@phimage commented on GitHub (Apr 16, 2018):

there is Decoder/Encoder implementation

I do not test it myself, someone else implement it
I do not know if there is unit test about it

<!-- gh-comment-id:381521967 --> @phimage commented on GitHub (Apr 16, 2018): there is Decoder/Encoder implementation I do not test it myself, someone else implement it I do not know if there is unit test about it
Author
Owner

@jrtibbetts commented on GitHub (Apr 21, 2018):

Yes, there is a Decoder/Encoder implementation, but it's not included in any released version of the code.

<!-- gh-comment-id:383269216 --> @jrtibbetts commented on GitHub (Apr 21, 2018): Yes, there is a Decoder/Encoder implementation, but it's not included in any released version of the code.
Author
Owner

@phimage commented on GitHub (Apr 21, 2018):

I will make a release for Xcode 9.3, swift 4.1

<!-- gh-comment-id:383269493 --> @phimage commented on GitHub (Apr 21, 2018): I will make a release for Xcode 9.3, swift 4.1
Author
Owner

@jrtibbetts commented on GitHub (May 5, 2018):

Have you been able to make a new release?

<!-- gh-comment-id:386780807 --> @jrtibbetts commented on GitHub (May 5, 2018): Have you been able to make a new release?
Author
Owner

@phimage commented on GitHub (May 5, 2018):

umm it's seems not? https://github.com/OAuthSwift/OAuthSwift/releases

github "OAuthSwift/OAuthSwift" "HEAD"

<!-- gh-comment-id:386782449 --> @phimage commented on GitHub (May 5, 2018): umm it's seems not? https://github.com/OAuthSwift/OAuthSwift/releases github "OAuthSwift/OAuthSwift" "HEAD"
Author
Owner

@maxep commented on GitHub (Jun 12, 2018):

Hey! master branch is working well with the Codable implementation. I'm also waiting for a release on CocoaPods. Thanks!

<!-- gh-comment-id:396513803 --> @maxep commented on GitHub (Jun 12, 2018): Hey! `master` branch is working well with the `Codable` implementation. I'm also waiting for a release on CocoaPods. Thanks!
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#296
No description provided.