Titanium.Cloud.accessToken error

You must Login before you can answer or comment on any questions.

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 undefined
I 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

— answered 8 months ago by Edward Sun
answer permalink
1 Comment
  • Edward,

    I am not using any Authorization Server, I am using ACS Cloud User in my application.

    Previously, In Titanium 2.1.1 I have used hasStoredSession( ) method to check stored user session(whether user logged in or not)

    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.

    — commented 8 months ago by prabu durai

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.

Your Answer

Think you can help? Login to answer this question!