Coder Social home page Coder Social logo

How do I get this running? about commerce HOT 14 CLOSED

vercel avatar vercel commented on April 30, 2024 6
How do I get this running?

from commerce.

Comments (14)

zeekrey avatar zeekrey commented on April 30, 2024 10

@RayeEThompson How does the Vercel CLI help me getting the right credentials? It will only store and receive credentials. But it won't magically generate them. Or am I wrong here? 🤔

This is my personal story. The needed data:

BIGCOMMERCE_STOREFRONT_API_URL=<>
BIGCOMMERCE_STOREFRONT_API_TOKEN=<>
BIGCOMMERCE_STORE_API_URL=<>
BIGCOMMERCE_STORE_API_TOKEN=<>
BIGCOMMERCE_STORE_API_CLIENT_ID=<>

I searched the whole BigCommerce docs but could only finde that I can obtain the following data from the BigCommerce dashboard:

  • Client Secret
  • Client ID
  • Access Token
  • API Path

This is documented here: BigCommerce Docs
I would derive the following mapping:

  • BIGCOMMERCE_STORE_API_TOKEN = Access Token
  • BIGCOMMERCE_STORE_API_CLIENT_ID = Client ID
  • BIGCOMMERCE_STORE_API_URL = API Path

For the storefront itself there are no credentials:

The Storefront API is unauthenticated, allowing you to make client-side requests for carts, checkouts, and orders using JavaScript.
Source

But, there are so called Storefront GraphQL credentials. To use them I need to create a JWT like explained here. So I would suppose that this is the BIGCOMMERCE_STOREFRONT_API_TOKEN. The BIGCOMMERCE_STOREFRONT_API_URL is the URL I see in the BigCommerce dashboard when I click on "View Store".

I'll try this now. Would be awesome if you could add the table below or any further information to the readme. ❤️

Variable Example Source
BIGCOMMERCE_STOREFRONT_API_URL https://store-{STORE_ID}.mybigcommerce.com/graphql BigCommerce dashboard, "View Store"
BIGCOMMERCE_STOREFRONT_API_TOKEN iyK2eXAiXiJKV1QiLCJhbGciOiJFUzI1NiJ... Should be generated: BigCommerce Docs
BIGCOMMERCE_STORE_API_URL https://api.bigcommerce.com/stores/{STORE_ID} BigCommerce dashboard, visible during the "Create API Account" process
BIGCOMMERCE_STORE_API_TOKEN iyK2eXAiXiJKV1QiLCJhbGciOiJFUzI1NiJ... BigCommerce dashboard, visible after the "Create API Account" process
BIGCOMMERCE_STORE_API_CLIENT_ID iyK2eXAiXiJKV1QiLCJhbGciOiJFUzI1NiJ... BigCommerce dashboard, visible afterthe "Create API Account" process

Edit: Added /graphql to BIGCOMMERCE_STOREFRONT_API_URL
Edit: Removed /v3 from BIGCOMMERCE_STORE_API_URL

from commerce.

thesobercoder avatar thesobercoder commented on April 30, 2024 7

Also for anyone willing to contribute, making it mandatory to sign up BigCommerce may actually discourage potential contributors.

from commerce.

StellaJung-Student avatar StellaJung-Student commented on April 30, 2024 4

@okbel for the new contributor~, how they know the proper values? Where can we get the API and Token~?

from commerce.

BilalDev avatar BilalDev commented on April 30, 2024 4

It should be as below:

BIGCOMMERCE_STOREFRONT_API_URL=https://store-${STORE_ID}.mybigcommerce.com/graphql
BIGCOMMERCE_STOREFRONT_API_TOKEN=${STOREFRONT_TOKEN}
BIGCOMMERCE_STORE_API_URL=https://api.bigcommerce.com/stores/${STORE_ID}
BIGCOMMERCE_STORE_API_TOKEN=${STORE_TOKEN}
BIGCOMMERCE_STORE_API_CLIENT_ID=${STORE_CLIENT}

With:
STORE_ID: you can get it from your bigcommerce dashboard URL,
STOREFRONT_TOKEN: easy way to get it is to go to Advanced Settings > Storefront API Playground and then pick the storefront_token from URL,
STORE_TOKEN|STORE_CLIENT: go to Advanced Settings > API Accounts then create a V2/V3 API Token.

from commerce.

markcmurphy avatar markcmurphy commented on April 30, 2024 2

Can anybody tell me where the env values are actually being used/called in the code?

They're being used in the @bigcommerce/storefront-data-hooks node module: node_modules@bigcommerce\storefront-data-hooks\api\index.js

from commerce.

millerized avatar millerized commented on April 30, 2024 1

It should be as below:

BIGCOMMERCE_STOREFRONT_API_URL=https://store-${STORE_ID}.mybigcommerce.com/graphql
BIGCOMMERCE_STOREFRONT_API_TOKEN=${STOREFRONT_TOKEN}
BIGCOMMERCE_STORE_API_URL=https://api.bigcommerce.com/stores/${STORE_ID}
BIGCOMMERCE_STORE_API_TOKEN=${STORE_TOKEN}
BIGCOMMERCE_STORE_API_CLIENT_ID=${STORE_CLIENT}

With:
STORE_ID: you can get it from your bigcommerce dashboard URL,
STOREFRONT_TOKEN: easy way to get it is to go to Advanced Settings > Storefront API Playground and then pick the storefront_token from URL,
STORE_TOKEN|STORE_CLIENT: go to Advanced Settings > API Accounts then create a V2/V3 API Token.

@BilalDev Thanks.

✅ My auth only works with the store token + store id version of the BIGCOMMERCE_STOREFRONT_API_URL e.g.

BIGCOMMERCE_STOREFRONT_API_URL=https://store-${STORE_TOKEN}-${STORE_ID}.mybigcommerce.com/graphql

🚫 These storefront api urls do not work with my generated API creds + storefront token:

https://${STORE_NAME}.mybigcommerce.com/graphql
https://store-${STORE_ID}.mybigcommerce.com/graphql

Hope this helps!

from commerce.

okbel avatar okbel commented on April 30, 2024

Hey @jpatters! I'm sorry you struggled to much to get this working! We updated our README a couple of days ago. Have you tried that? Pulling the env vars? LMK! And thanks for the feedback!

@thesobercoder We're currently working on supporting more data providers so stay tuned!

from commerce.

David05500 avatar David05500 commented on April 30, 2024

@okbel for the new contributor~, how they know the proper values? Where can we get the API and Token~?

Have you managed to figure out yet?

from commerce.

StellaJung-Student avatar StellaJung-Student commented on April 30, 2024

@David05500 Yeah.. any tips?

from commerce.

David05500 avatar David05500 commented on April 30, 2024

@David05500 Yeah.. any tips?

Unfortunately I am looking for the answer myself!

from commerce.

RayeEThompson avatar RayeEThompson commented on April 30, 2024

In BigCommerce you can get the API tokens from the Store's control panel - you can refer to our documentation on authentication here: https://developer.bigcommerce.com/api-docs/getting-started/authentication/rest-api-authentication
You will also need a graphql auth token: https://developer.bigcommerce.com/api-reference/store-management/tokens/api-token/createtoken

The easiest way to connect however, is to use the Vercel CLI and pull your .env.local. This is part of the native integration ;)

from commerce.

RayeEThompson avatar RayeEThompson commented on April 30, 2024

You will need to use the Vercel CLI and use the cmd for pull .env.local, as long as you used the native integration.
The Storefront API URL should contain the /graphql endpoint. Everything else looks correct.

from commerce.

bryandandan avatar bryandandan commented on April 30, 2024

Can anybody tell me where the env values are actually being used/called in the code?

from commerce.

bryandandan avatar bryandandan commented on April 30, 2024

Correct. Thank you!

from commerce.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.