Connect OAuth provider with Client Keys Salt Edge now supports Account Information Services channels, which can be used with PSD2 and Open Banking compliant APIs.
Read about it in Salt Edge Documentation
-
Register application deep-link (Custom URL Scheme, in example below it'll be
custom_scheme
) for your app target. See official Apple documentation. -
Create a
returnTo
constant as application deep link, which you will use forcreateConnectSession
.static let returnTo = "custom_scheme://custom_host/custom_path"
-
Fetch providers and select one.
let params = SEProviderParams(fromId: 108) SERequestManager.shared.getProviders(with: params) { response in // handle response here. }
-
Create Connect Session. In
SEConnectSessionsParams
addSEAttempt
object with yourreturnTo
url.let params = SEConnectSessionsParams( attempt: SEAttempt(returnTo: returnTo), providerCode: provider?.code, disableProvidersSearch: true, consent: consent ) SERequestManager.shared.createConnectSession( params: params, completion: { [weak self] response in // Use recieved response.connectUrl self?.handleConnectSessionResponse(response) } )
-
Check Provier
mode
. Ifmode
isoauth
then open receivedconnectUrl
in external app, otherwise open it inwebView
.func handleConnectSessionResponse(_ response: SEConnectSessionResponse) { guard let url = URL(string: response.connectUrl) else { return } // Check if provider mode is "oauth". Then try to open it in external browser or app. if let provider = self.provider, provider.isOAuth, UIApplication.shared.canOpenURL(url) { UIApplication.shared.open(url) } else { let request = URLRequest(url: url) webView.load(request) } }
-
All connect operations (Authorizations, Fetching, etc.) will be performed in external app.
-
After openning your app with
deepLink
, handle it in yourAppDelegate.swift
, using next method:func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { SERequestManager.shared.handleOpen(url: url, connectionFetchingDelegate: yourDelegate) return true }
The most common case of Salt Edge Connect usage is when TPP application initiate connect of Account and opens Salt Edge Connect url in WKWebView. There are a lot of banks which require authentication/authorization in bank applications, but in that case redirection outside of saltedge.com will remain in WKWebView and flow will get stuck.
First solution is to open all Salt Edge Connect URL's (or URL's for oauth
providers) in external browser/application.
Second solution is to open Salt Edge Connect in the WKWebView and handle all redirections outside Salt Edge (saltedge.com) and open them in external browser/application.
Instead of WKWebView you can open url in SFSafariViewController.
After successful authentication user will be redirected back to TPP app.
We propose to use deep-link with custom scheme (like: mytpp://domain.name/action
) as return url.
Same type of deeplink uniquely identify your application in the system and eliminate doubts where to redirect, as well as they are easy to implement.
Copyright © 2014 Salt Edge Inc. https://www.saltedge.com