robertofrontado / RxSocialConnect-iOS

OAuth RxSwift extension for iOS.
Apache License 2.0
26 stars 3 forks source link

Would there be a way for us to customize it and not use social media outlets? #12

Closed rlam3 closed 7 years ago

rlam3 commented 7 years ago

Would there be a way for us to customize it and not use social media outlets? And call upon private servers? Thanks!

robertofrontado commented 7 years ago

Hello @rlam3 I don't understand the question, what do you mean with social media outlets?

What do you want to do? use OAuth with your server? something like that?

If you want to use with a different provider that is not included in my library, you need to do the following:

There are 2 protocolos: ProviderOAuth1 and ProviderOAuth20

If you want to use OAuth v2 you need to create a class that confroms ProviderOAuth20 protocol:

open class FacebookApi20: ProviderOAuth20 {

    open var consumerKey: String
    open var consumerSecret: String
    open var callbackUrl: URL
    open var scope: String

    open var authorizeUrl: String = "https://www.facebook.com/dialog/oauth"
    open var accessTokenUrl: String = "https://graph.facebook.com/oauth/access_token"
    open var responseType: String = "token"

    required public init(consumerKey: String, consumerSecret: String, callbackUrl: URL, scope: String) {
        self.consumerKey = consumerKey
        self.consumerSecret = consumerSecret
        self.callbackUrl = callbackUrl
        self.scope = scope
    }
}

And for OAuth v1 create a class that conforms ProviderOAuth1 protocol:

import OAuthSwift

open class TwitterApi: ProviderOAuth1 {

    open var consumerKey: String
    open var consumerSecret: String
    open var callbackUrl: URL

    open var requestTokenUrl: String = "https://api.twitter.com/oauth/request_token"
    open var authorizeUrl: String = "https://api.twitter.com/oauth/authorize"
    open var accessTokenUrl: String = "https://api.twitter.com/oauth/access_token"

    required public init(consumerKey: String, consumerSecret: String, callbackUrl: URL) {
        self.consumerKey = consumerKey
        self.consumerSecret = consumerSecret
        self.callbackUrl = callbackUrl
    }

}
rlam3 commented 7 years ago

@robertofrontado Thanks for your reply.

I'm actually doing JWT auth process instead of OAuth. https://jwt.io/introduction/

I was wondering if your cocoapod would support JWT directly with my own server. Or maybe in the future? Protocol may be similar in fashion but requires a little bit of tweaking.

http://www.seedbox.com/en/blog/2015/06/05/oauth-2-vs-json-web-tokens-comment-securiser-un-api/

Thanks!

robertofrontado commented 7 years ago

@rlam3 Sorry for the delay,

Right now it's not working with JWT auth process, only OAuth, also in the near future, I don't have any plans of implementing JWT in this library 😅. Although it would be an useful feature.

But if you want to do it, feel free to open a PR, I'll be more than glad to review and merge it 👍