Donald Charity
Posts: 0
Joined: Thu Feb 06, 2014 2:58 pm

get session cookie from REST API login page

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

get session cookie from REST API login page

Hello! Working on it, I'll update.

Donald Charity
Posts: 0
Joined: Thu Feb 06, 2014 2:58 pm

get session cookie from REST API login page

Thanks Maryna!

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

get session cookie from REST API login page

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...

Donald Charity
Posts: 0
Joined: Thu Feb 06, 2014 2:58 pm

get session cookie from REST API login page

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?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

get session cookie from REST API login page

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

Donald Charity
Posts: 0
Joined: Thu Feb 06, 2014 2:58 pm

get session cookie from REST API login page

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.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

get session cookie from REST API login page

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

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

get session cookie from REST API login page

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?

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

get session cookie from REST API login page

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?

Return to “Issues”