[GH-ISSUE #100] A few questions on specific usage of OAuthSwift #61

Closed
opened 2026-03-03 16:45:19 +03:00 by kerem · 2 comments
Owner

Originally created by @damianesteban on GitHub (Aug 28, 2015).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/100

I have OAuth all setup and working fine for my application's authorization but I have a few questions that I'm hoping someone can answer:

1.) Does OAuthSwift provide a way to store the token in the keychain? Does it do so by default?

2.) The authorization examples are great, but is there a basic example that shows how to make a GET request with the access token?

Thank you.

Originally created by @damianesteban on GitHub (Aug 28, 2015). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/100 I have OAuth all setup and working fine for my application's authorization but I have a few questions that I'm hoping someone can answer: 1.) Does OAuthSwift provide a way to store the token in the keychain? Does it do so by default? 2.) The authorization examples are great, but is there a basic example that shows how to make a GET request with the access token? Thank you.
kerem closed this issue 2026-03-03 16:45:19 +03:00
Author
Owner

@phimage commented on GitHub (Aug 29, 2015):

1/ no keychain store, but there is encoding and decoding method into OAuthSwiftCredential
So you can archive into nsdata and store in keychain

I make a framework for preferences and there is keychain storing
https://github.com/phimage/Prephirences/

let keychain = KeychainPreferences.sharedInstance
keychain.setObjectToArchive(theCredential, "a string key")

if let retrievedCredential = keychain.unarchiveObjectForKey("the same key") {.. }

or with subscript and explicit archiving

keychain["a string key"] = NSKeyedArchiver.archivedDataWithRootObject(theCredential)

if let data = keychain["a string key"] as? NSData  {
    let retrievedCredential = NSKeyedUnarchiver.unarchiveObjectWithData(data)

}

2/ look into demo app
there is some get request with automatic use of credential in http header

oauthswift.client.get(...

but you can do it manually , see code like #99

<!-- gh-comment-id:135981326 --> @phimage commented on GitHub (Aug 29, 2015): 1/ no keychain store, but there is encoding and decoding method into OAuthSwiftCredential So you can archive into nsdata and store in keychain I make a framework for preferences and there is keychain storing https://github.com/phimage/Prephirences/ ``` swift let keychain = KeychainPreferences.sharedInstance keychain.setObjectToArchive(theCredential, "a string key") if let retrievedCredential = keychain.unarchiveObjectForKey("the same key") {.. } ``` or with subscript and explicit archiving ``` swift keychain["a string key"] = NSKeyedArchiver.archivedDataWithRootObject(theCredential) if let data = keychain["a string key"] as? NSData { let retrievedCredential = NSKeyedUnarchiver.unarchiveObjectWithData(data) } ``` 2/ look into demo app there is some get request with automatic use of credential in http header ``` swift oauthswift.client.get(... ``` but you can do it manually , see code like #99
Author
Owner

@damianesteban commented on GitHub (Aug 29, 2015):

Thanks a lot, this helped tremendously.

<!-- gh-comment-id:135995870 --> @damianesteban commented on GitHub (Aug 29, 2015): Thanks a lot, this helped tremendously.
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#61
No description provided.