Page 4 of 4

How do I check if the session token is still active?

Posted: Fri Nov 20, 2015 6:06 am
by Yurii Orishchuk

Hi Jack,

You need to use following syntax for invoking service datasource with parameters:

pre

var request = {
//Here you can specify header parameters
headers: {someHeader: "someValue"},
//Specify url string parameters. (works in all HTTP methods)
parameters: {"www": "aa"},
//Specify body parameters. (not supports by "GET" or "DELETE" methods, see RFC for details).
body: {"bdf": "123"}
};

checkService.execute(request);

/pre

Regards.


How do I check if the session token is still active?

Posted: Thu Mar 24, 2016 12:27 pm
by Mike Townsend

Hi Yuri,

I wonder if you can help me please, I'm really struggling with validating a user is logged in, I have checked I have the correct
DatabaseID,
userID,
Token
As the user was only logged in seconds before - can you point out what is wrong with the following ajax please which i'm running through a jquery plugin ajaxq.

Using a similar approach it works fine to log users in but now I can't seem to validate them afterwards. I have read all the similar links on this but there must be a small adjustment i can make to the below to get it to work? Rather than a more complicated approach.

var ajaxRequest = {

url: encodeURIComponent("https://api.appery.io/rest/1/db/users/" +myUserID),

dataType: 'json',
cache: 'false',
type: 'get',
crossDomain: true,
headers: {
'X-Appery-Database-Id': myDatabaseID,
'X-Appery-Session-Token': mySessionToken
},
timeout: 10000,
success: checkValid_success,
error: checkValid_fail
};
$.ajaxq("myqueue", ajaxRequest);

Thanks for taking a look,
Mike


How do I check if the session token is still active?

Posted: Thu Mar 24, 2016 1:03 pm
by Mike Townsend

Hi Yuri,

I've answered my own question minutes after posting it - even though I was struggling for hours on it - I've realised the above ajaxq approach works just fine if the url is not encoded. I'll leave the question there in case it is useful for others searching for solutions at any point (let me know if you want me to delete it).

I do have another question tho, I can't get the 'find' to work.

Can you give me some advice please on how I can get the ajaxq approach outlined above working using the REST API - FIND which is specified as this:

curl -X GET \
-H "X-Appery-Database-Id: " \
-H "X-Appery-Session-Token: " \
-G --data-urlencode 'where={"":""}' \
https://api.appery.io/rest/1/db/users

I suspect my problem is specifying the url properly, mine is specified as this:

var myUrl = encodeURIComponent("https://api.appery.io/rest/1/db/users...':'" +myUserID +"'}")

thanks in advance
Mike


How do I check if the session token is still active?

Posted: Thu Mar 24, 2016 7:51 pm
by Serhii Kulibaba

Hello Mike,

Sory, you code is broken. Please use tag "pre" or "code" to wrap your code (https://getsatisfaction.com/some.html).
What are you trying to do? Do you need to get user's data? If so, please use request below for that: https://devcenter.appery.io/documenta...


How do I check if the session token is still active?

Posted: Sat May 28, 2016 11:08 pm
by AndyM

I may be missing something but creating timers and calling a service to check if a login token has expired seems like an overkill..
I assume that if a service tries to use a token that expired it will get an error "invalid session token" or something like that
Why not just call User.login(..) at that point?
Am i overlooking something?
Thanks
Andy


How do I check if the session token is still active?

Posted: Mon May 30, 2016 8:54 pm
by Serhii Kulibaba

Hello Andy,

You are talking about social login plugin, but the topic is about general functionality.