Skip to content

Latest commit

 

History

History
94 lines (70 loc) · 4.04 KB

HOWTO.md

File metadata and controls

94 lines (70 loc) · 4.04 KB

How To...


Connect OAuth provider with Client Keys

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

  1. Register application deep-link (Custom URL Scheme, in example below it'll be custom_scheme) for your app target. See official Apple documentation.

  2. Create a returnTo constant as application deep link, which you will use for createConnectSession.

    static let returnTo = "custom_scheme://custom_host/custom_path"
  3. Fetch providers and select one.

    let params = SEProviderParams(fromId: 108)
    SERequestManager.shared.getProviders(with: params) { response in
        // handle response here.
    }
  4. Create Connect Session. In SEConnectSessionsParams add SEAttempt object with your returnTo 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)
        }
    )
  5. Check Provier mode. If mode is oauth then open received connectUrl in external app, otherwise open it in webView.

    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)
        }
    }
  6. All connect operations (Authorizations, Fetching, etc.) will be performed in external app.

  7. After openning your app with deepLink, handle it in your AppDelegate.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
        }

App-2-App redirect

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.
app-2-app redirect base flow

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.
app-2-app redirect hybrid flow

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