Parsing JSON in Bubble Workflow

Not sure why, but Bubble has stopped parsing a JSON response from a Shopify API.

When a store signs up, we get an X-Shopify-Access-Token along with the scopes of access to the store account. This has been working for 18 months.

Now the data is coming back in the error text x-shopify-access-token, scope but when the workflow tries to write them into individual columns, nothing is there. Not sure why it’s in the error text and I am unable to parse it on the key and value.

Not sure if I even can reinitialize this workflow because it is reliant on unique tokens from Shopify during the OAuth process.



Did you activate detect request header and continue workflow if error?

Yeah - it’s been on from the start. The challenge is that the code used in the OAuth is a single random code from Shopify. So I cannot actually reinitialize without a unique code from Shopify. Most of the components to get the X-Acces-Token are pulled from URL parameters, an HMAC value and a ShopifyCallbackCode (which I actually capture and store).

The first step is the Authorize and the second step is the OAuth Call Back where the acces-token is sent (and you can only capture it once).

Normally, you can always request a new access_token (but you will need to also get a new code). If you have detect header, normally, you should reach JSON structure with a 's body step first. Your screenshot doesn’t show that, so I don’t think this is activated. If you didn’t make any change, you may reach Bubble support for this issue.

1 Like

This is from Shopify’s site on OAuth…

{
“access_token”: “f85632530bf277ec9ac6f649fc327f17”,
“scope”: “write_orders,read_customers”
}

The return is correct, even the access_token, scope and raw body text are showing the response from Shopify as the options in the workflow. And when I write the raw body text to a column, the JSON content is there. For whatever reason, the flow is not splitting it out.

You can request a new token but it requires reinstalling the app. I cannot initialize without the code from Shopify (big circle :wink:

I ended up using this regex to extract the value from the raw body text

{
“access_token”: “f85632530bf277ec9ac6f649fc327f17”,
“scope”: “write_orders,read_customers”
}

used the data from the api response

result of Step 1 Shopify Access Token raw body tex:extractWithRegex

(?<=“access_token”:“)[^”]+

that extracts the token only and writes it to the table.

repeat process with scope

It works for now.

1 Like