Page 1 of 2

get session cookie from REST API login page

Posted: Thu Feb 06, 2014 2:58 pm
by Donald Charity

My parameters are my username and password which are passed in correctly but my response is just the html page saying success, when I do it in a stand alone browse the cookie is stored and I can access other pages normally.

How do I capture the cookie with my app here and use it to make other rest api calls?

Image


get session cookie from REST API login page

Posted: Thu Feb 06, 2014 6:22 pm
by Maryna Brodina

Hello! Working on it, I'll update.


get session cookie from REST API login page

Posted: Thu Feb 06, 2014 6:34 pm
by Donald Charity

Thanks Maryna!


get session cookie from REST API login page

Posted: Thu Feb 06, 2014 6:35 pm
by Maryna Brodina

You won't get cookie from service response, but they're set automatically. After they are set you can get them using document.cookie https://developer.mozilla.org/en-US/d...


get session cookie from REST API login page

Posted: Thu Feb 06, 2014 6:54 pm
by Donald Charity

ok I tried "document.cookie" it doesn't give me the authentication cookie from my domain it gives me appery.io's cookie? any ideas?


get session cookie from REST API login page

Posted: Thu Feb 06, 2014 8:33 pm
by Maryna Brodina

Please check in console what service returns? Does it return cookie you need?


get session cookie from REST API login page

Posted: Thu Feb 06, 2014 9:43 pm
by Donald Charity

looking at the console, yes, the correct cookie is there, but when I try to retrieve it with document.cookie to use in other request that needs the session cookie it gives me a cookie from appery.


get session cookie from REST API login page

Posted: Thu Feb 06, 2014 10:39 pm
by Maryna Brodina

Sorry for misunderstanding. To get cookie you need to send ajax request with parameter withCredentials = true and service should respond with header Access-Control-Allow-Credentials: true (requests through Proxy won't work). Cookies will be retrieved and saved, but you can't read them because they are saved for your site, not Appery.io. But cookie can be sent https://developer.mozilla.org/en-US/d...
Services created in Appery.io by default work with withCredentials = false, so you need to call your service through JS, for example prerestserviceName.execute({xhrFields: {
withCredentials: true
}
})/pre


get session cookie from REST API login page

Posted: Mon May 19, 2014 1:53 pm
by Dupdroid

Good day,

I've got the same issue as above.

------------

My parameters are my username and password which are passed in correctly but my response is just the html page saying success, when I do it in a stand alone browse the cookie is stored and I can access other pages normally.

How do I capture the cookie with my app here and use it to make other rest api calls?

------------

I have tried the javascript suggestion but I'm getting the following error when running the app:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.appery.io/rest/1/proxy/tu.... This can be fixed by moving the resource to the same domain or enabling CORS.

I have tried the proxy option also because in another post I thought I read that this is what the proxy resolves but I see in the above response the proxy won't work. This is a bit confusing to me.

Any suggestions?


get session cookie from REST API login page

Posted: Mon May 19, 2014 2:28 pm
by Dupdroid

I have also noticed the following description as part of the CORS error:

{"code":"PTCT010","description":"Mandatory parameter 'appery-rest' is missing"}

What does this mean?