API Store Authentication gadget help

  • 1
  • Problem
  • Updated 4 years ago
  • Solved
I am having trouble with the Store Authentication Gadget:
 [gadgets.rpc.register("rsparam_set_" + your_gadget_id, response);]

First I am not clear if the 'your_gadget_id' refers to the product ID. I have tried a Product ID for the widget that I am testing but it seems that it is not passing a value to the response function. 

My logic is as follows:
  • gadgets.rpc.call("", "rsparam_get", null, id, "displayId");
  • gadgets.rpc.register("rsparam_set_" + product_id, response);
  • response(name,value)
  • ajax call to store
  • ajax success find authentication bool
  • if true proceed
  • set refresh time
  • call every hour
  • if false stop, throw error
Debug shows it stepping over the second step .

Thanks in advance.
Photo of j Guzman

j Guzman

  • 210 Points 100 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Blake Freeman

Blake Freeman, Official Rep

  • 36,116 Points 20k badge 2x thumb

Thanks for the post. Let me look into this and I'll get back to you.
Photo of Alex D.

Alex D., Employee

  • 1,038 Points 1k badge 2x thumb
Hi there,

The Store authorization process you're trying to set up has been implemented in one of our common libraries:

What you'll need to do to access it is add the following files from the dist folder to your HTML:

To use this, you'll have to initialize the object:
var _auth = new RiseVision.Common.Store.Auth();
and call the checkForDisplay function:
_auth.checkForDisplay(displayId, productCode, function(authorized) {

As for retrieving the Display Id, I believe the reason why your debugging process is stopping at the second step is because you're registering the callback (gadgets.rpc.register) after you do the call (gadgets.rpc.call). Try to reverse those two statements to see if it fixes it. Something like:
gadgets.rpc.register("rsparam_set_" + id, RiseVision.Financial.Table.setParams);
gadgets.rpc.call("", "rsparam_get", null, id, ["additionalParams", "displayId", "companyId"]);
If that still doesn't work, you can take a look at one of our widgets' implementation for this:

Finally, the Product Id is a value obtained from the Store. I'm not exactly sure what the best way to obtain that is, so someone else will have to address that answer.

Let me know if you have any further questions or encounter any issues.

Photo of j Guzman

j Guzman

  • 210 Points 100 badge 2x thumb
Hi Alex,
Hope ur having a great holiday. If you are on the clock by any chance i have implemented the  RiseVision.Common.Store.Auth(); and I am getting a 500 server error when it hits:

numbers intentionally replaced with x

Failed to load resource: The server responded with a status of 500 (Internal Server Error) https://store-dot-rvaserver2.appspot.com/v1/widget/auth?id=sxxxxxxxx &pc=xxxxxxxxxx

Would you have any pointers?
Photo of Alex D.

Alex D., Employee

  • 1,038 Points 1k badge 2x thumb
Hi J,

I can't confirm which of the requests are from your widget, but I'm seeing 500 errors from this URL:

to confirm, id=sc0_pre0_ph0_0 seems to be the ID of the Widget, not the Display.

If that URL your Widget is calling, can you make sure you're sending a the correct Display Id?

Photo of j Guzman

j Guzman

  • 210 Points 100 badge 2x thumb
thank you, you are right it is the ID of the widget.