Ugh… so this is all starting to ring a bell from a discussion I had years ago
https://mail-archives.apache.org/mod_mbox/shindig-dev/201112.mbox/%3cof8eaceec4.629d7942-on8525796f.005711e2-8525796f.00572...@notesdev.ibm.com%3E and https://issues.apache.org/jira/browse/SHINDIG-1557 In that bug I suggested that the calls to userPrefs were being made on behalf of the container, in other words the container security token was being used. This might be working as designed, but it means on the service side I can't just do token.getModuleId(). Instead I always need to pass along the extra piece of information to the service. Dan Dumont suggested… I think we would certainly want to make sure that all container-proxied requests ferry along the moduleId. I'll keep that in mind as I make these changes. Thank you for pointing it out. I don’t think those were changes that were ever made. That’s fine, I can just switch my userPrefs to key off of moduleId (instead of siteId) and just pass it along, but I was hoping to not even have to do that since the gadget security token has the moduleId embedded appropriately. At least I’ve wrapped my head around the moduleId stuff. Not sure if it buys me anything at this point however. Hmph! doug On Apr 27, 2015, at 12:47 PM, Davies,Douglas <davi...@oclc.org<mailto:davi...@oclc.org>> wrote: Doh! I just realized that the validate method has to return the same value. I changed it and I’m now getting back the moduleId in the json response. Sweet! So to summarize… If I set RenderParam.MODULE_ID to -1 it causes the back-end to generate an id using ModuleIdManager (generate and validate). This comes back in the json response to the “gadget.token” rpc call. Thereafter, if I call gadgetSite.getModuleId() I get back the generated id. Now if I set RenderParam.MODULE_ID to 1234 and I don’t provide my own ModuleIdManager, it will return a moduleId of 0. If I instead implement the validate method (the generate does not get called in this scenario) to return the moduleId passed in then the module id is set correctly and I can use gadgetSite.getModuleId() as well. I hope that helps someone else in the future. Is there somewhere I could document this? Not sure where the correct wiki is anymore and whether this falls under common container info or what. Thanks! doug On Apr 27, 2015, at 11:35 AM, Davies,Douglas <davi...@oclc.org<mailto:davi...@oclc.org>> wrote: If I set renderParams[osapi.container.RenderParam.MODULE_ID] = -1 per http://comments.gmane.org/gmane.comp.web.shindig.devel/8498 * You can now request that a new moduleId be generated for a gadget when asking for a new token by setting it's moduleId to a negative number and fetching a new token. The response will come back with a moduleId you can save for persistence. There is a corresponding new class in Java to override if you plan on persisting moduleIds. It has 2 methods: validate and generate which are used to verify the validity of a moduleId, viewerId, gadgetUrl combination or to generate (and persist) a new moduleId for that combination. I now see the “generate” method of ModuleIdManager get called. I have it returning 1234L. However, the response still has moduleId set to 0. [{"method":"gadgets.token","id":"gadgets.token","params":{"container":"sandbox","ids":["https://dl.dropboxusercontent.com/u/445894/gadgets/userprefs-consistency.xml#moduleId=-1"],"fields":["token","tokenTTL","moduleId"],"userId":"@viewer","groupId":"@self"}}] [{"result":{"https://dl.dropboxusercontent.com/u/445894/gadgets/userprefs-consistency.xml#moduleId=-1":{"moduleId":0,"responseTimeMs":1430148807688,"tokenTTL":3600,"token":"sandbox:hdaOrK8oPiHzbXbZqWfCReLpNJ2rgioN3pIXAX33ChO9r6rxBgB9DOHkp02PzPD7xOIwYD5MpEDB0DFjVceBq-VRnFm2xCDpIbft5CpbF8r1nQP5VLRoxf4bbsxFG13vEso2adn9eBGg516thh7MtHa-i5Om-fxkH8ycXCLsFeZPqqIS1vEgLahykYYcoaGrbwxZfNDtGfLl9pH9bXIqpjkAArpWyiABVz_5C-6AE2I0xoc8LJIjZylSDrrqxN9GQUbp5gGa3yny5Qu5GG2GqSQeSrUaTm2tjQc3n15mlSUjBjt_LqjZ8_laeChEfVJOO2FurZO1uWOXoKzB4LIQZyZTDhoQ8Vxzsa0KZpT4JmdRRmKlMh7IiJAZmc9WTVEBHffJ_KYl3pHT11JmOjvbDS9t8rltEyDtxf4TOnmLFDosIdJcNTAiBv8nv5l6sm2o7CJRRGhQvhqStNUYVS0etReoCw9T8hTVZSKeAC5F1-Ew7qOjghLK3SsLPxXJZSRVnZ3xsolOQ9CAiRe852KhhpkBsvlCpW82r4N-wresRASzMOgM"}},"id":"gadgets.token”}] doug