function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kamal Agarwal 10Kamal Agarwal 10 

How to read refresh token through salesforce mobile native iOS SDK

I have integrated salesforce mobile native iOS SDK in my project which is in swift. Now after user login I want to read-refresh and access token but I have not found any method or class which gives me refresh and access token.
Best Answer chosen by Kamal Agarwal 10
Tristan BurnsideTristan Burnside
The credentials property on the account (which isn't included in the description string) has properties for access and refresh tokens.

All Answers

Tristan BurnsideTristan Burnside
Have you looked at `SFUserAccountManager`. It has a list of accounts in the property `allUserAccounts`?
Kamal Agarwal 10Kamal Agarwal 10
Yes, I have already tried SFUserAccountManager but it is not providing refresh token and access token. Below is the output which I am getting.

 identifier="3MVG9Zdl7Yn6QDKMCsJWeIlvKopZ7msQYyL8QxLvD3E8Yd49Gt1N2HApGbrEtOMMU6x9yWuvY20_l5YTR5u6w-2996293072" clientId="3MVG9Zdl7Yn6QDKMCsJWeIlvKopZ7msQYyL8QxLvD3E8Yd49Gt1N2HApGbrEtOMMU6x9yWuvY20_l5YTR5u6w" domain="login.salesforce.com" identityUrl="https://login.salesforce.com/id/00D770000000YtEAE/00577000000UknSAAP" instanceUrl="https://login.salesforce.com" communityId="(null)" communityUrl="(null)" issuedAt="2017-10-26 07:15:42 +0000" organizationId="00D770000000Zq9DRD" protocol="https" redirectUri="testsfdc:///mobilesdk/detect/oauth/done">, community=(null)
 
Tristan BurnsideTristan Burnside
The credentials property on the account (which isn't included in the description string) has properties for access and refresh tokens.
This was selected as the best answer
Kamal Agarwal 10Kamal Agarwal 10
Thanks, Tristan. Through below code I am getting the access token and refresh token. 

SFUserAccountManager.sharedInstance().currentUser?.credentials.accessToken
SFUserAccountManager.sharedInstance().currentUser?.credentials.refreshToken

One thing I want to ask can we get to know expiration of access token and refresh token?
Kamal Agarwal 10Kamal Agarwal 10
How we know expiration of access token and refresh token?