In Titanium 2.1.1, I used hasStoredSession( ) method to check stored user session.
Since this method was DEPRECATED from 2.1.2, so now I am trying to use Titanium.Cloud.accessToken method to check the stored user session.
But I am getting below error
Uncaught TypeError: Cannot read property 'accessToken' of undefinedI am using Titanium 2.1.3 and ti.cloud 2.3.0.
3 Answers
Hi, for the "User Authentication Scheme" configuration, maybe you should use the "Authorization Server" to sign in your users, then you will get the accessToken, which is not undefined any more
according to my understanding, the 'accessToken' is used to store a String, which will be generated when a user does the 'sign in'. And, the 'sign in' is the 'log in' method when a cloud App is set to use 'Authorization Server'. So, if you don't use the 'Authorization Server', you don't use the 'sign in' method, as a result, you don't have values stored as the 'accessToken'
Here is the Docs:
accessToken : String Identifies the current access token when using 3-Legged OAuth
Contains the access token after successfully calling Titanium.Cloud.Users.secureCreate or Titanium.Cloud.Users.secureLogin, and null after successfully calling Titanium.Cloud.Users.logout.
All calls made using the Cloud module automatically use this value and, thus, it only needs to be used when manually making calls to the ACS servers using Titanium.Network.HTTPClient.
The accessToken is not persisted across application sessions by the module. An application can persist the accessToken by saving the value in secure storage and restoring the value of this property in the next application session.
The accessToken is not used with 2-legged OAuth or API key authentication; use sessionId instead.
if (Cloud.hasStoredSession) still works for me using ACS.
Your Answer
Think you can help? Login to answer this question!