For an app to access financial data by calling the Customer Account Data API, it must be authorized to make the call. The Java Customer Account Data SDK uses OAuth for authorization. When your app makes a call to Customer Account Data service API, the SDK obtains OAuth information from Intuit, builds an instance of Context object and uses the Context object as an authorization parameter in all calls to Customer Account Data services.
Integrate your app with the Customer Account Data API by creating an Customer Account Data integration at the Intuit Developer site.
The following steps describe how the SDK builds the Context object.
A valid OAuthAuthorizer object ensures that an end-user is authorized to access financial data using your app. When your app uses the DevKit to invoke an Customer Account Data API, the SDK does the following to build an OAuthAuthorizer object:
The DevKit sends a SAML assertion to the Intuit OAuth server, obtains the OAuth Access Tokens in the background and proceeds to build the OAuthAuthorizer object. To re-use the OAuth Access Tokens you may cache the OAuthAuthorizer object and use it until the tokens expires or until the session expires, whichever comes first.
The following code snippet shows how to create an OAuthAuthorizer object with the following parameters:
String consumerKey = ... String consumerSecret = ... String samlProviderId = ... String subject = ... OAuthAuthorizer oauth = new OAuthAuthorizer(consumerKey, consumerSecret, samlProviderId, subject);
The DevKit uses the OAuthUtil class to obtain OAuth Credentials and then retrieves the OAuth Access Tokens by using the getOAuthTokens(). You can then pass the OAuthCredentials object as a parameter to build the OAuthAuthorizer object. To re-use the OAuth Access Tokens, you may cache the OAuthCredentials object or the OAuthAuthorizer object and use it until the tokens expire or until the session expires, whichever comes first.
The following steps show how to obtain OAuth Access Tokens and build the OAuthAuthorizer object:
String consumerKey = ... String samlProviderId = ... String subject = ... OAuthUtil oauthUtil = new OAuthUtil(consumerKey,samlProviderId, subject);
OAuthCredentials oauthCredentials = oauthUtil.getOAuthTokens();
OAuthCredentials oauthCredentials = new OAuthCredentials(); oauthCredentials.setAccessToken("accessToken"); oauthCredentials.setAccessTokenSecret("accessTokenSecret");
String consumerKey = ... String consumerSecret = ... OAuthAuthorizer oauth = new OAuthAuthorizer(consumerKey, consumerSecret, oauthCredentials);
The following code snippet shows how to create an instance of the Context class using the reference to the OAuthAuthorizer object:
Context context = new Context(oauth)