Heimdallr.swift
Heimdallr.swift copied to clipboard
New built-in OAuth Access Token Store: iCloud Key-Value Storage
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
-
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?
-
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.
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?