Spree generic implementation for api token

馋奶兔 提交于 2019-12-24 11:26:49

问题


I an deleting items from spree cart using the following spree api url

/api/orders/#{current_order.number}/line_items/#{line_iem.id}?line_item[variant_id]=#{line_item.variant.id}&line_item[quantity]=0&token=MyToken

the token used here is of a single user. I want to implement this in generic way so that it can be used for both guest and registered user.. is it possible?

any help would be highly appreciated

Regards


回答1:


Whenever you create an order using the Spree API, you get an order_token in the response. From the Spree API Guide:

The order_token parameter will work for authorizing any action for an order within Spree’s API.

So instead of appending &token=... you should append &order_token=...

It will work for both registered users as well as guests.



来源:https://stackoverflow.com/questions/32285209/spree-generic-implementation-for-api-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!