[GH-ISSUE #642] Confused about how credential should be persisted and repopulated. #421

Closed
opened 2026-03-03 16:48:33 +03:00 by kerem · 1 comment
Owner

Originally created by @ashrobo on GitHub (Jan 10, 2021).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/642

Description:

I have the OAuth mechanism working end to end, however I'm confused about how the credentials should be persisted. I'm using NSKeyedArchiver to covert the credentials to data which I'm then storing in the keychain in response to the application being terminated. On re-launch I'm checking if the keychain contains any credentials, if so I'm using NSKeyedUnarchiver to reconstruct the credential object but at this point I'm unable to set the credentials back on the SwiftOAuth Client object as the property is get only?

I want to ensure future calls to startAuthorizedRequest use my persisted credentials rather than asking the user to log in again each time the application is killed, what's the correct way to handle this?

OAuth Provider? (Twitter, Github, ..):

OAuth Version:

  • Version 1
  • Version 2

OS (Please fill the version) :

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

Installation method:

  • Carthage
  • CocoaPods
  • Swift Package Manager
  • Manually

Library version:

  • head
  • v2.1.0
  • v2.0.0
  • v1.4.1
  • other: (Please fill in the version you are using.)

Xcode version:

  • 11.4 (Swift 5.2)

  • 11.x (Swift 5.1)

  • 10.x (Swift 5.0)

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

  • objective c

Originally created by @ashrobo on GitHub (Jan 10, 2021). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/642 ### Description: I have the OAuth mechanism working end to end, however I'm confused about how the credentials should be persisted. I'm using NSKeyedArchiver to covert the credentials to data which I'm then storing in the keychain in response to the application being terminated. On re-launch I'm checking if the keychain contains any credentials, if so I'm using NSKeyedUnarchiver to reconstruct the credential object but at this point I'm unable to set the credentials back on the SwiftOAuth Client object as the property is get only? I want to ensure future calls to startAuthorizedRequest use my persisted credentials rather than asking the user to log in again each time the application is killed, what's the correct way to handle this? ### OAuth Provider? (Twitter, Github, ..): ### OAuth Version: - [x] Version 1 - [ ] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [x] CocoaPods - [ ] Swift Package Manager - [ ] Manually ### Library version: - [ ] head - [x] v2.1.0 - [ ] v2.0.0 - [ ] v1.4.1 - [ ] other: (Please fill in the version you are using.) ### Xcode version: - [ ] 11.4 (Swift 5.2) - [ ] 11.x (Swift 5.1) - [ ] 10.x (Swift 5.0) - [x] other: (Please fill in the version you are using.) - 12.1 - [ ] objective c
kerem closed this issue 2026-03-03 16:48:33 +03:00
Author
Owner

@phimage commented on GitHub (Apr 2, 2021):

https://github.com/OAuthSwift/OAuthSwift/wiki/Store-credential

<!-- gh-comment-id:812638560 --> @phimage commented on GitHub (Apr 2, 2021): https://github.com/OAuthSwift/OAuthSwift/wiki/Store-credential
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#421
No description provided.