License | MIT |
ReleasedLast Release | Mar 2017 |
Maintained by Alex Moskvin, Bogdan Laukhin.
This repo contains CocoaPods plugin code for implementing Sequencing.com's OAuth2 authentication for your Swift iOS app so that your app can securely access Sequencing.com's API and app chains.
Please follow instruction below if you want to install and use OAuth logic in your existed or new project.
Create a new project in Xcode
Install pod
$ pod init
use_frameworks!
specify "sequencing-oauth-api-swift" pod parameters:
pod 'sequencing-oauth-api-swift', '~> 2.5.0'
install the dependency in your project: $ pod install
$ open *.xcworkspace
Add Application Transport Security setting
App Transport Security Settings
row parameter (as Dictionary)Exception Domains
dictionary parametersequencing.com
string valueAllow Arbitrary Loads
boolean valueAllow Arbitrary Loads
boolean value as YES
Register framework to use in Swift code
first of all you need to create bridging header file. Select File > New > File > Header File > name it as
project-name-Bridging-Header.h
add SQOAuthFramework class import in the bridging header file
#import <OAuth/SQOAuthFramework.h>
register your bridging header file in the project settings. select your project > project target > Build Settings > Objective-C Bridging Header specify path for bridging header file
$(PROJECT_DIR)/project-name-Bridging-Header.h
Register app parameters and delegate
subscribe your class for Authorization protocol
SQAuthorizationProtocol
have access to SQOAuth via shared instance
method
SQOAuth.sharedInstance()
register your app parameters and delegate
SQOAuth.sharedInstance().registerApplicationParametersCliendID(client_id,
clientSecret: client_secret,
redirectUri: redirect_uri,
scope: scope,
delegate: self)
where:
client_id - your app CLIENT_ID
client_secret - your app CLIENT_SECRET
redirect_uri - your app REDIRECT_URI
scope - your app SCOPE
delegate - UIViewController instance that conform to "SQAuthorizationProtocol" protocol
Use authorization method
implement methods from SQAuthorizationProtocol
func userIsSuccessfullyAuthorized(_ token: SQToken) -> Void { }
func userIsNotAuthorized() -> Void { }
func userDidCancelAuthorization() -> Void { }
you can authorize your user via authorizeUser
method
SQOAuth.sharedInstance().authorizeUser()
in method userIsSuccessfullyAuthorized
you'll receive the SQToken object:
accessToken: String
expirationDate: NSDate
tokenType: String
scope: String
refreshToken: String
Access to up-to-date token
SQOAuth.sharedInstance().token { (token) in
}
Register new account / Reset password methods
callRegisterResetAccountFlow
method - it will open dialog popup
SQOAuth.sharedInstance().callRegisterResetAccountFlow()
This repo is actively maintained by Sequencing.com. Email the Sequencing.com bioinformatics team at gittaca@sequencing.com if you require any more information or just to say hola.
We encourage you to passionately fork us. If interested in updating the master branch, please send us a pull request. If the changes contribute positively, we'll let it ride.