Search in sources :

Example 1 with AccMgrAuthTokenProvider

use of com.salesforce.androidsdk.rest.ClientManager.AccMgrAuthTokenProvider in project SalesforceMobileSDK-Android by forcedotcom.

the class PushService method getRestClient.

private RestClient getRestClient(UserAccount account) {
    final ClientManager cm = SalesforceSDKManager.getInstance().getClientManager();
    RestClient client = null;
    /*
    	 * The reason we can't directly call 'peekRestClient()' here is because
    	 * ClientManager does not hand out a rest client when a logout is in
    	 * progress. Hence, we build a rest client here manually, with the
    	 * available data in the 'account' object.
    	 */
    if (cm != null) {
        try {
            final AccMgrAuthTokenProvider authTokenProvider = new AccMgrAuthTokenProvider(cm, account.getInstanceServer(), account.getAuthToken(), account.getRefreshToken());
            final ClientInfo clientInfo = new ClientInfo(new URI(account.getInstanceServer()), new URI(account.getLoginServer()), new URI(account.getIdUrl()), account.getAccountName(), account.getUsername(), account.getUserId(), account.getOrgId(), account.getCommunityId(), account.getCommunityUrl(), account.getFirstName(), account.getLastName(), account.getDisplayName(), account.getEmail(), account.getPhotoUrl(), account.getThumbnailUrl(), account.getAdditionalOauthValues(), account.getLightningDomain(), account.getLightningSid(), account.getVFDomain(), account.getVFSid(), account.getContentDomain(), account.getContentSid(), account.getCSRFToken());
            client = new RestClient(clientInfo, account.getAuthToken(), HttpAccess.DEFAULT, authTokenProvider);
        } catch (Exception e) {
            SalesforceSDKLogger.e(TAG, "Failed to get rest client", e);
        }
    }
    return client;
}
Also used : ClientManager(com.salesforce.androidsdk.rest.ClientManager) RestClient(com.salesforce.androidsdk.rest.RestClient) ClientInfo(com.salesforce.androidsdk.rest.RestClient.ClientInfo) URI(java.net.URI) IOException(java.io.IOException) AccMgrAuthTokenProvider(com.salesforce.androidsdk.rest.ClientManager.AccMgrAuthTokenProvider)

Aggregations

ClientManager (com.salesforce.androidsdk.rest.ClientManager)1 AccMgrAuthTokenProvider (com.salesforce.androidsdk.rest.ClientManager.AccMgrAuthTokenProvider)1 RestClient (com.salesforce.androidsdk.rest.RestClient)1 ClientInfo (com.salesforce.androidsdk.rest.RestClient.ClientInfo)1 IOException (java.io.IOException)1 URI (java.net.URI)1