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;
}
Aggregations