I want to connect to the ERP with my Google Apps Script. But I got 403 error even after signing in. Here is my code:
var response=UrlFetchApp.fetch('http://some.site/api/method/login?usr=user@some.site&pwd=password', {method:"POST"});
// Result: {"home_page":"/desk","message":"Logged In","full_name":"User Name"}
var response2=UrlFetchApp.fetch('http://some.site/api/method/frappe.auth.get_logged_user');
// Result: Request failed for http://some.site/api/method/frappe.auth.get_logged_user returned code 403.
So far, I thought it was because the session is finished before executing the second code, but I still got the same error even after changed into this:
var response=UrlFetchApp.fetch('http://some.site/api/method/login?usr=user@some.site&pwd=password', {method:"POST"});
var response2=UrlFetchApp.fetch('http://some.site/api/method/frappe.auth.get_logged_user', {"headers": {"Cookie": response.getAllHeaders()['Set-Cookie']}});
Please help. Thank you.