App To Web Single Sign On
App to Web Single Sign On allows you to take a session from your mobile application and extend it to a browser on the same device. This is useful for giving a seamless experience to your users when they transition from the mobile application to the website where more functionality likely exists. This functionality can only be used when using the Onegini CIM identity provider as it is a unique feature of the Onegini Consumer Identity Manager. This can be configured in the Onegini Token Server Admin.
The Onegini SDK allow you to specify a target URL where authentication is required. This URL must be configured in the Action Token configuration of the Onegini Consumer Identity Manager. It will then verify that your mobile application's session is valid and establish a session with the Identity provider before redirecting the user to the target URL with them automatically logged in.
To use the functionality, call the appToWebSingleSignOnWithTargetUrl:completion:
method on ONGUserClient
with target URL as a parameter and completion block.
In case of success, a URL will be returned which need to be opened in a web browser. The SDK will also provide a token param as a convenience. In case of failure an error will be returned. The returned errors will be within the
ONGGenericErrorDomain or ONGAppToWebSingleSignOnErrorDomain.
Example code
Swift
guard let targetURL = URL(string: "https://demo-cim.onegini.com/personal/dashboard") else { return }
ONGUserClient.sharedInstance().appToWebSingleSignOn(withTargetUrl: targetURL) { (url, token, error) in
if let url = url {
// Open url in web browser
} else if let error = error {
// Handle error
}
}
Objective-C
NSURL *targetURL = [NSURL URLWithString:@"https://demo-cim.onegini.com/personal/dashboard"];
[ONGUserClient.sharedInstance appToWebSingleSignOnWithTargetUrl:targetURL completion:^(NSURL * _Nullable url, NSString * _Nullable token, NSError * _Nullable error) {
if (url) {
// Open url in web browser
} else {
// Handle error
}
}];