BigCommerce API OAuth服务器到服务器脚本(BigCommerce API OAuth server to server script)

编程入门 行业动态 更新时间:2024-10-28 00:25:32
BigCommerce API OAuth服务器到服务器脚本(BigCommerce API OAuth server to server script)

连接到BigCommerce API的最新规范建议使用OAuth,因为简单的auth方法很快就会被弃用。

我一直在一些PHP脚本中使用BigCommerce API来访问我的商店的Store API。 这些脚本执行相对简单的操作,例如更新产品名称,更新产品价格等。

我对如何将这些脚本转移到使用新的OAuth系统感到困惑。 我正在阅读的所有内容都使得OAuth基于开发用户安装和授权访问其商店的实际应用程序。 但是,这显然不是我的用例,而且让我很困惑。

一个简单的例子是从我的商店检索产品的脚本。 我只是在PHP文件中运行此代码:

Bigcommerce::configure(array( 'store_url' => 'https://www.my-store.com', 'username' => 'my_username', 'api_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx' )); Bigcommerce::setCipher('RC4-SHA'); Bigcommerce::verifyPeer(false); Bigcommmerce::getProducts();

如何使用OAuth实现同样的功能? 它甚至可能吗?

The latest specification for connecting to the BigCommerce API recommends using OAuth since the simple auth method will soon be deprecated.

I have been using the BigCommerce API within some PHP scripts that access the Store API for my store. These scripts do relatively simple things like update product names, update product prices, etc.

I'm confused as to how I transfer these scripts over to use the new OAuth system. Everything I am reading makes it seem like OAuth is based around developing an actual app that a user installs and authorizes to access their store. However, this is clearly not my use case, and has left me very confused.

A simple example would be a script to retrieve products from my store. I would simply run this code in a PHP file:

Bigcommerce::configure(array( 'store_url' => 'https://www.my-store.com', 'username' => 'my_username', 'api_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx' )); Bigcommerce::setCipher('RC4-SHA'); Bigcommerce::verifyPeer(false); Bigcommmerce::getProducts();

How can I achieve this same thing using OAuth? Is it even possible?

最满意答案

我可能会创建一个快速“应用程序”来获取客户端ID,客户端密钥和令牌。 然后使用这些凭据进行外部身份验证 因此,您将安装“身份验证应用程序”,但从BC外部执行您的代码。

请注意,这与iframed的已安装应用程序的工作方式没有什么不同。

PS,我实际上没有试过这个,但理论上它应该有效。

I would probably create a quick "app" to get a Client ID, Client Secret & Token. Then use those credentials for authentication externally. So you would install an "authentication app" but execute your code from outside of BC.

Note that this is not that different from how an installed app that is iframed in works.

PS, I have not actually tried this but in theory it should work.

更多推荐

本文发布于:2023-08-04 21:08:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1422037.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:服务器   脚本   API   BigCommerce   OAuth

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!