flyingL123 flyingL123 - 1 year ago 169
PHP Question

BigCommerce API OAuth server to server script

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:

'store_url' => '',
'username' => 'my_username',
'api_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'


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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download