trivago / Heimdallr.swift

Easy to use OAuth 2 library for iOS, written in Swift.
Apache License 2.0
639 stars 86 forks source link

New built-in OAuth Access Token Store: iCloud Key-Value Storage #85

Open fabiomassimo opened 8 years ago

fabiomassimo commented 8 years ago

Summary

Added a new OAuth Access Token Store base on iCloud Key-Value Storage.

Why

I wanted to have the opportunity to store access token information in a shared container accessible from other devices that do not have capabilities to support the OAuth 2 authentication process (like tvOS). By using this new built in store, the user can rely on the iCloud Key-Value Storage, connected to his personal iCloud account, to share authentication information retreived from other devices.

Notes

1) I'm not sure how to write tests for this feature. The new class I created his heavily coupled with a valid iCloud Key-Value Storage. Any idea?

2) It would be nice to improve the OAuthAccessTokenStore protocol with a proper callback method that notifies when a new access token has been set. Currently, if new information have been sent from another device, the user has to manually query the iCloud Key-Value Store again to retrieve new information.

hffmnn commented 8 years ago

Hi and thanks for your contribution!

I had a look and I think this is definitely the right way to go!

Regarding testing I would try the following: Inject the store as a dependency, so that you can mock that out in test (via Dobby). And then you could verify, that the expected methods on the store get called.

Regarding the OAuthAccessTokenStore protocol: Can you sketch out/show/code up what you have in mind?