delba / swiftyoauth Goto Github PK
View Code? Open in Web Editor NEWA simple OAuth library for iOS with a built-in set of providers
License: MIT License
A simple OAuth library for iOS with a built-in set of providers
License: MIT License
From the docs:
Step 2: Handle the incoming requests
Handle the incoming requests in your AppDelegate:
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
github.handleURL(url, options: options)
return true
}
Unfortunately, while I was following the README, I found out that that the delegate method signature is slightly different:
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool
This causes an inconsistency with the designated method to handle an URL from the Provider.
/**
Handles the incoming URL.
- parameter URL: The incoming URL to handle.
- parameter options: A dictionary of launch options.
*/
public func handleURL(URL: NSURL, options: [String : AnyObject])
I think it should be rewritten in something like:
public func handleURL(URL: NSURL, sourceApplication: String?)
Such that the Step 2 from the README would look like:
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
github.handleURL(url, sourceApplication: sourceApplication)
return true
}
If I want/need to write my own TokenStore, I need to be able to store/recreate the Token. The easiest way is to do Token.dictionary, convert to Data and then store. And the opposite would be easy, if you make your init public, instead of internal.
Is there a reason for it to be internal..?
The description says iOS. I want to use for OSX Mac App. Is it possible?
Attempt to present <SFSafariViewController: 0x7fc7ba018400> on <MyOauth.ViewController: 0x7fc7b860b070> whose view is not in the window hierarchy!
Carthage
and CocoaPods
are awesome tools and make our life really easier, but there are some devs who still don't know how to use them.
It would be cool to add the Manual installation guide in your README.md
. You can take a look at my iOS Readme Template to see how you can do it.
I was trying to perform a login with Google Service.
Hereby the executed code
let provider = Provider.Google(clientID: "$(the_client_id)", clientSecret: "$(the_client_secret)", redirectURL: "$(bundle_identifier):/urn:ietf:wg:oauth:2.0:oob")
provider.scopes = ["https://www.googleapis.com/auth/analytics.readonly"]
provider.authorize(self) { (result) in
switch result {
case .Success(let token):
print(token)
case .Failure(let error):
print(error)
}
When the authorisation is granted in the Safari View Controller the redirect URL gets triggered with following format:
$(bundle_identifier):/urn:ietf:wg:oauth:2.0:oob?code=$(the_authorization_code)
This cause an issue for when the library checks if the redirect URL use during the initialisation of the Provider matches the received redirect URL from the AppDelegate
.
I've tried other combination of redirect URL but that's the redirect URL format that the Google guide advocates.
Did anyone experienced this when trying the built in Google Provider?
I think an easy fix would be to match the retrieved URL by removing the GET parameter from the URL but before open a new PR I'd like to receive some feedback about this.
Self-signed certificates are very common in developer environments. Network calls are done using static function on HTTP
struct and with URLSession.shared
which silently ignores auth challenges and simply leads to failure branch.
Does anyone have SwiftyOAuth working with the Xcode 8 GM? I marked the completion blocks in Provider
as @escaping
where necessary and it is building fine but the issue now is that the new method in the AppDelegate
to open urls now has the following signature:
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool
so the Provider
method handleURL
is not working.
Great library by the way. It's nice and lightweight and has the Result
type built-in. SwiftyOAuth is definitely going to be my default OAuth library from now on.
I don't understand how to do this? Can anyone guide me please
In Token.swift, this init makes the all 3 parameters mandatory:
guard let
accessToken = json["access_token"] as? String,
tokenType = json["token_type"] as? String,
scope = json["scope"] as? String
else { return nil }
However, Instagram only returns access_token
{
"access_token": "2342264381.bc3c943.6086017a221b427a997e4928f0ea197b",
"user": {
...
}
}
What do you think about this:
internal init?(json: JSON) {
guard let
accessToken = json["access_token"] as? String
else { return nil }
self.accessToken = accessToken
self.tokenType = json["token_type"] as? String ?? ""
self.scope = json["scope"] as? String ?? ""
self.dictionary = json
}
The OAuth Authentication process nowadays can be triggered from many devices equipped with different os: watch OS, iOS, tvOS.
Unfortunately, not all of this operating system can rely on a safe way to implement the OAuth 2.0 authentication flow:
SafariServices
or Webkit.SafariServices
or Webkit.My idea to address this issue would be to implement for SwiftyOAuth
following goals:
-authorize
method depending on current platform and capabilities.What do you think?
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:
http://oauth.net/grant_type/device/1.0
Provider
with support to request an access token with new grant type.A planned increase in OS X support ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.