TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | Apache 2 |
ReleasedLast Release | Jun 2018 |
SPMSupports SPM | ✗ |
Maintained by Jørund B. Fagerjord, Atanas Bakalov.
Depends on: | |
AeroGearHttp | >= 0 |
JSONWebToken | >= 0 |
OAuth2 Client based on aerogear-ios-http.
Swift 4.0
Please use the GitHub Watch feature to get notified on new releases of the SDK.
The easiest way to get started is looking at the Hello World example app.
https://github.com/telenordigital/TelenorConnectIosHelloWorld.
Implements the API's for http://docs.telenordigital.com/apis/connect/id/authentication.html.
Documentation on the project forked from can be found at https://aerogear.org/docs/guides/aerogear-ios-2.X/
Clone this project
Get the dependencies
The project uses CocoaPods for handling its dependencies. As a pre-requisite, install CocoaPods and then install the pod. On the root directory of the project run:
pod install
To add the library in your project, you can either use CocoaPods or manual install in your project. See the respective sections below for instructions:
In your Podfile
add:
pod 'TDConnectIosSdk'
and then:
pod install
to install your dependencies
Follow these steps to add the library in your Swift project:
git submodule add https://github.com/telenordigital/connect-ios-sdk.git
connect-ios-sdk
folder, and drag the TDConnectIosSdk.xcodeproj
into the file navigator in Xcode.TDConnectIosSdk.framework
.+
button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add TDConnectIosSdk.framework
.To set the SDK to Confidential Client mode set the optional init parameter in the Config
object named isPublicClient
to false
. Otherwise it will default to a public client.
A confidential client will not exchange the authorization code but simply return this to the client through the callback. The app code can then send this to the server-side component of the client.
See http://docs.telenordigital.com/connect/id/native_apps.html for more information.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let config = TelenorConnectConfig(clientId: "telenordigital-connectexample-ios",
redirectUrl: "telenordigital-connectexample-ios://oauth2callback",
useStaging: true,
scopes: ["profile", "openid", "email"],
accountId: "telenor-connect-ios-hello-world",
isPublicClient: false) // this variable needs to be present
let oauth2Module = AccountManager.getAccountBy(config: config)
?? AccountManager.addAccountWith(config: self.config, moduleClass: TelenorConnectOAuth2Module.self)
oauth2Module.requestAuthorizationCode { (authorizationCode: AnyObject?, error: NSError?) in
if (error != nil) {
// handle error
return
}
// use authorizationCode
}
}