Moqui session token

A question:
I am right when i am saying the moquiSessionToken is not used in the REST interface?

Regards,
Hans at growerp.com

I disabled providing session tokens when using the REST interface and everything still working ok…

so to answer the question myself: no it is not used.

however should it be used?

If I recall correctly, the moquiSessionToken is for POST events to prevent xss POST in client side js.

1 Like

at the moment i do not provide a moquiSessionToken when accessing via the REST interface, and it is not giving me an error, so my understanding the moquiSessionToken is not used here?

I think that’s because you accessed a no-auth API. MoquiSessionToken is needed for authorized activities

1 Like

Yeah that’s right, and by default POST events from the REST API or transitions require authentication.

Thank for your replies, however below is a POST request of creating a company from a user who is logged in using the api_key but no moqui session token:
β•”β•£ Request β•‘ POST
β•‘ http://localhost:8080/rest/s1/growerp/100/Company
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
β•” Headers
β•Ÿ content-type: application/json
β•Ÿ api_key: auM6cutFfsdyo7XAnpp4CiHkrGB6DCHTKxvgExiY
β•Ÿ contentType: application/json
β•Ÿ responseType: ResponseType.json
β•Ÿ followRedirects: true
β•Ÿ connectTimeout: 0:00:05.000000
β•Ÿ receiveTimeout: 0:00:10.000000
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
β•” Extras
β•Ÿ requireApiKey: true
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
β•” Body
β•Ÿ company: Company name: Test company[null] Curr: imgSize: null#Empl: 0
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
β•‘ {company: Company name: Test company[null] Curr: imgSize: null#Empl: 0}

β•”β•£ Response β•‘ POST β•‘ Status: 200 OK
β•‘ http://localhost:8080/rest/s1/growerp/100/Company
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
β•” Headers
β•Ÿ access-control-allow-credentials: [true]
β•Ÿ access-control-allow-origin: [http://localhost:39775]
β•Ÿ content-length: [183]
β•Ÿ content-type: [application/json]
β•Ÿ expires: [Thu, 01 Jan 1970 00:00:00 GMT]
β•Ÿ moquisessiontoken: [Nuaie-twmMBE908G7FpS]
β•Ÿ x-csrf-token: [Nuaie-twmMBE908G7FpS]
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
β•” Body
β•‘
β•‘ {
β•‘ company: {
β•‘ partyId: β€œ102217”,
β•‘ pseudoId: β€œ102217”,
β•‘ name: β€œTest company”,
β•‘ role: β€œCustomer”,
β•‘ email: β€œβ€,
β•‘ currency: null,
β•‘ image: null,
β•‘ address: null,
β•‘ vatPerc: β€œ0”,
β•‘ salesPerc: β€œ0”,
β•‘ paymentMethod: null,
β•‘ telephoneNr: β€œβ€,
β•‘ employees:
β•‘ }
β•‘ }
β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

If You need need more info about the system please check github at : GitHub - growerp/growerp: GrowERP Flutter ERP for Android, IOS and Web using Moqui.org, Apache OFBiz the moqui system is in the directory β€˜moqui’

Thanks for you help!
regards,
Hans

1 Like

There is an api_key in your request header. Moqui will call log-in with that key and the sessionToken is not needed any more. In other words, your are doing re-login in every request.
Notice that the moquiSessionToken is present in the response header, you should capture it for use in next requests, to save server resources.

1 Like

Thank you for the answer, very useful, will try it,
Regards,
Hans