SwiftyOAuth
SwiftyOAuth copied to clipboard
Support OAuth 2.0 Device Flow
Device flow's goal is to implement OAuth 2.0 authorisation flow on devices with limited capabilities (i.e. no WebKit).
In my overview to support this:
- [ ] Add new grant type:
http://oauth.net/grant_type/device/1.0
- [ ] Handle new error cases: "authorisation_pending" , "slow_down", "code_expired"
- [ ] Extend the
Provider
with support to request an access token with new grant type.
Do you have a use case in mind?
OAuth 2.0 through an Apple TV.
-
The user starts the handshake for requesting a device code depending on the provider requirements. This process involves a POST request to a proper URL. The specification about this are given by the provider. Here an example for Google.
-
The user presents the proper UI in the app and asks to
SwiftyOAuth
to pull an access token through something like
public func authorizeDeviceCode(deviceCode: String, completion: Result<Token, Error>)
- A proper Access Token is returned and saved like usual.
I edited the function signature. I thing the retry mechanism should be up to the user not to SwiftyOAuth
.
@fabiomassimo Check out the upcoming single sign-on feature for Apple TV :)
I guess we can close the issue?
Unfortunately not, because it is only supported by apps that provide broadcasting content (HBO, CNN)
Please if you think this issue is not in scope feel free to close this. Otherwise I'd be happy to provide a PR for it. As far as I know this could be a first in the OAuth library out there.
It's not out of the scope but it has to fit well in the lib. I don't want the implementation to be in the way of the more mainstream flows.
Also, while the multi-platform support is on the roadmap, there are other things I'd like to do first (Keychain etc.). Once these things out of the way, yes I'm all for it :)
@fabiomassimo What's the status on it ? 😃
Hi Damien, Sorry I didn't give you any update on this.
While doing my research I found this following nice implementations about Apple Keychain:
- Heimdlarr: Easy drop in class solution.
- Apple: Little bit too academic but gives nice hands on the Security Framework.
I wanted to make my own implementation as exercise but unexpected events made me really busy on something else. If you want to move forward I think I've to leave this to you.
The keychain concern has already been taken care of ahaha https://github.com/delba/SwiftyOAuth/tree/keychain
I'm gonna merge it in master soon
That's awesome!
Device Flow was already implemented in my personal fork.
I can merge from current keychain branch if you want to and open a PR with just Device Flow implementation.
Yes, could you please rebase your work with the keychain branch and submit a PR?
I might merge everything in master by tomorrow
Hi @fabiomassimo !
Just FYI I created a swift-3.0
branch 🚀 😄