Hi guys,I'm working ok an Chrome Extension to improve Gerrit Experience. For that I'm using Gerrit REST API with restful.js.For all normal requests that method work pretty fine.
But I could not perform a POST request, to submit a review for example.Please, consider this code:api = restful(options.gerritUrl).prefixUrl(options.prefix);var obj = {"labels":{"Code-Review":2},"strict_labels":true,"drafts":"PUBLISH_ALL_REVISIONS"};api.all("a/changes/{id}/revisions/{revision}/review/").post(obj).then(function(response){console.log(response)}).catch(function (error) {console.log(error)})I always get an 403 error saying "Invalid authentication method. In order to authenticate, prefix the REST endpoint URL with /a/ (e.g. http://example.com/a/projects/)."But as you can see I'm already using "a/changes" as required.
Debugging a real request made by an user interaction I can see a "X-Gerrit-Auth" property on header. But I could not find any specification on how to find it or how to use it on a request
--
--
To unsubscribe, email repo-discuss+unsubscribe@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en
---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
What are the "normal" requests?I guess it worked for all requests where anonymous access was allowed.
There are two ways to authenticate a REST API call. Either use the /a/ prefix and perform the http basic/digest authentication (whatever is configuredfor the Gerrit server) or, like the Gerrit UI does, include both the GerritAccount cookie and the X-Gerrit-Auth header in the request.
AFAIK, the value of the X-Gerrit-Auth header is only available in the client JS code.I don't know if chrome extensions can read it.
What are the "normal" requests?I guess it worked for all requests where anonymous access was allowed.Sorry, you are right. I've meant requests allowed to be made anonymously.There are two ways to authenticate a REST API call. Either use the /a/ prefix and perform the http basic/digest authentication (whatever is configuredfor the Gerrit server) or, like the Gerrit UI does, include both the GerritAccount cookie and the X-Gerrit-Auth header in the request.Yes, but I'm doing that
--
you are including the /a/ but where is the Authorization header?
I am not an expert in this area but I believe that this is not possible.UI/JS experts please correct me if I am wrong.The X-Gerrit-Auth value is intended to stay as hidden as possible because it is a protection against XSRF.