OAuth Integration
Introduction
Starting January 2021, our bank verification partner has entered into data access agreements with Chase, Capital One, JP Morgan Chase, Wells Fargo, Bank of America, and US Bank to start migrating into new financial access channels. As a part of this agreement, the bank verification will need to be done using an OAuth integration. This is an industry-standard authentication protocol for data sharing, which will give users increased control and transparency while improving overall connection stability.
Overview of Bank Add Changes
In general, there are two ways to handle bank API: OAuth and non-OAuth. The existing bank add flow utilizes a non-OAuth flow and the user stays within the bank widget throughout the authentication and authorization process.
However, the OAuth flow requires the user to authenticate their account on their bank’s website. This means that the user will begin the bank add process from the existing widget however, they will be temporarily redirected to their Bank’s website to login and give permission after which, they are brought back to the bank add widget to complete the flow.
Banks Currently supporting OAuth Flow
Chase
Capital One
Wells Fargo
Bank of America
USAA
U.S. Bank
Robinhood
Supporting OAuth Banks
In order to support OAuth banks, your work will mostly be limited to your front-end bank widget integration. Not all banks will support OAuth flow and you will only be able to tell whether a bank follows OAuth or Non-OAuth flow after the user has selected their bank. Therefore, we suggest you make the changes outlined below regardless of the banks you want to support.
The below integration guidelines are recommendations and the best integration for your service may vary.
Widget for Web
For non-OAuth bank, all events will need to be completed in Machnet's widget.
Add an OAuth bank
User opens the bank widget
User selects a bank that requires OAuth login
Users will be redirected to the bank website.
Once the authorization is completed, the user is redirected back to the widget iframe. All redirections will be handled by the widget itself.
OAuth bank relogin will be similar to re-login of other banks. Please refer to the bank re-login section below for additional details.
Widget for mobile application
For non-OAuth bank, all events will need to be completed in the widget in webview.
You need to host the widget separately in a web server as a web application. The hosted page will receive all the necessary parameters through query param ie. token, senderId etc. This integration recommendation will require the following steps.
Create a web page for the widget. A sample code is here.
The web page will have an index.html page. Index page will contain the bank widget and deep link URL in apps.
Index page should receive all the necessary parameters through query parameters. As of now, we have set up the following parameters in the sample snippet.
token: widget token received from Machnet
senderId: sender reference id received from Machnet
brand: your brand name
bankRelogin: true is bank re-login is required
bankId: sender bank id inorder to load bank re-login widget
Note: You can add any other necessary params as per your requirement. A recommended way to pass query parameters is to hash or encode base64 query param values for security reasons.
While adding bank from the mobile app (iOS and android),
User clicks on add bank
User needs to be redirected to an external browser with the widget page link and necessary parameters.
Example
If the widget web page is hosted on https://widget.example.com, the apps should redirect users to https://widget.example.com?token=<Base64Encoded-token-value>&senderId=<Base64Encoded-sender-id-value>&brand=<brand-name> in an external browser.
Once the user completes adding a bank from the widget web page, users will be displayed with a success message and “Goto App” button.
On the mobile app, developers need to handle the deep link using app schemes. Whenever the user clicks on the “Goto App” button, the user should be returned to the same state where the user left the app.
Once a user is returned to the app, the bank list needs to be re-fetched so the user can see the newly added bank.
Sample code and steps for integration
Creating widget web page
Create index.html file with following code.
Host these page in web server.
With this setup the widget web page is ready for integration in the app.
Integrating widget app in the apps
For the integration we need to handle web events and deep linking using App Url schemes. To set up Deep Linking in an app, additional configuration is required in Xcode for iOS and Android Studio for Android. Outlined below are the steps.
iOS
Adding App Url Scheme and Identifier
Open your Xcode project and go to the "Info" tab.
Then go to the very bottom and click the plus (+) sign under URL Types. Make sure to add url-scheme as your new Identifier and specify URL Schemes as url-scheme.
In the "URL Schemes" section, enter a unique string that will identify your app. This string should be all lowercase and may include numbers and hyphens, but no spaces or special characters. In the identification and url schemes field, enter your unique app scheme.
Add new line in podfile.
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
On your appDelegate.m file import the following.
#import <React/RCTLinkingManager.h>
Insert the following in appDelegate.m file.
Android
Open your Android Studio project and go to the "AndroidManifest.xml" file. Add an intent filter to your app's main activity, with the following information:
Adding App Url Scheme and Identifier
Finalize the configuration by setting the scheme to url-scheme and defining the main route as route-name.
<data android:scheme="CUSTOM_URL_SCHEME" android:host="your-url-host" />
Replace your-url-scheme with a unique string that will identify your app. This string should be all lowercase and may include numbers and hyphens, but no spaces or special characters.
Add Intent within your activity tag, save your changes and build your app.
React Native Codebase
Once the above changes have been made, in your App.js file import Linking from ‘react-native’.
You can use the Linking API to listen for changes to the app's deep link URL. To do this, you can use the addEventListener method to register a listener for the url event. Remember to also remove the event listener when it is no longer needed, using the removeEventListener method.
For example,
When the program is opened, the initial URL is retrieved using the Linking.getInitialURL()
method. Deep linking uses the Linking.addEventListener
method to add the event listener that watches for urls and calls the callback method you passed it.
Use the handleDeepLinking
function to check if the url includes the custom app scheme and handle it accordingly.
Widget Component
Once the widget is loaded check if Widget has widgetToken and referenceId. If the widgetType is bank then open the bank widget url in the default browser. To do that import Linking API from react-native and use openUrl function. openUrl function takes the URL as a parameter.
This opens the bank widget url in the browser and allows you to complete the process in the browser. Once the process is complete, the url provides an event that can be handled as described earlier in the document.
The WebView component code has been shown below.
OAuth Bank Relogin
When added bank status is moved to LOGIN_REQUIRED, following parameters need to be passed while loading bank widget inorder to re-login to bank account.
bankRelogin [true]
bankId [Base64 Encoded Bank Id]
Last updated