title: MERN Stack Development - StripeAuthenticationError
body: <p>When I go for Checkout It's giving error. The following error occurs. Please someone help.</p>
  <p>Error:
  {
  &quot;type&quot;: &quot;StripeAuthenticationError&quot;,
  &quot;raw&quot;: {
  &quot;message&quot;: &quot;You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). See <a href="https://stripe.com/docs/api#authentication" rel="nofollow noreferrer">https://stripe.com/docs/api#authentication</a> for details, or we can help at <a href="https://support.stripe.com/.%22" rel="nofollow noreferrer">https://support.stripe.com/.&quot;</a>,
  &quot;type&quot;: &quot;invalid_request_error&quot;,
  &quot;headers&quot;: {
  &quot;server&quot;: &quot;nginx&quot;,
  &quot;date&quot;: &quot;Mon, 04 Oct 2021 04:55:24 GMT&quot;,
  &quot;content-type&quot;: &quot;application/json&quot;,
  &quot;content-length&quot;: &quot;343&quot;,
  &quot;connection&quot;: &quot;keep-alive&quot;,
  &quot;access-control-allow-credentials&quot;: &quot;true&quot;,
  &quot;access-control-allow-methods&quot;: &quot;GET, POST, HEAD, OPTIONS, DELETE&quot;,
  &quot;access-control-allow-origin&quot;: &quot;<em>&quot;,
  &quot;access-control-expose-headers&quot;: &quot;Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required&quot;,
  &quot;access-control-max-age&quot;: &quot;300&quot;,
  &quot;cache-control&quot;: &quot;no-cache, no-store&quot;,
  &quot;www-authenticate&quot;: &quot;Basic realm=&quot;Stripe&quot;&quot;,
  &quot;strict-transport-security&quot;: &quot;max-age=31556926; includeSubDomains; preload&quot;
  },
  &quot;statusCode&quot;: 401
  },
  &quot;rawType&quot;: &quot;invalid_request_error&quot;,
  &quot;headers&quot;: {
  &quot;server&quot;: &quot;nginx&quot;,
  &quot;date&quot;: &quot;Mon, 04 Oct 2021 04:55:24 GMT&quot;,
  &quot;content-type&quot;: &quot;application/json&quot;,
  &quot;content-length&quot;: &quot;343&quot;,
  &quot;connection&quot;: &quot;keep-alive&quot;,
  &quot;access-control-allow-credentials&quot;: &quot;true&quot;,
  &quot;access-control-allow-methods&quot;: &quot;GET, POST, HEAD, OPTIONS, DELETE&quot;,
  &quot;access-control-allow-origin&quot;: &quot;</em>&quot;,
  &quot;access-control-expose-headers&quot;: &quot;Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required&quot;,
  &quot;access-control-max-age&quot;: &quot;300&quot;,
  &quot;cache-control&quot;: &quot;no-cache, no-store&quot;,
  &quot;www-authenticate&quot;: &quot;Basic realm=&quot;Stripe&quot;&quot;,
  &quot;strict-transport-security&quot;: &quot;max-age=31556926; includeSubDomains; preload&quot;
  },
  &quot;statusCode&quot;: 401
  }</p>
  <pre><code>const Cart = () =&gt; {
    const cart = useSelector((state) =&gt; state.cart);
    const [stripeToken, setstripeToken] = useState(null);
    const history = useHistory();
  
    const onToken = (token) =&gt; {
      setstripeToken(token);
      console.log(token);
    };
  
    useEffect(() =&gt; {
      const makeRequest = async () =&gt; {
        try {
          const res = await userRequest.post(&quot;/checkout/payment&quot;, {
            tokenId: stripeToken.id,
            amount: cart.total,          
          });
          
          history.push(&quot;/success&quot;, { data: res.data });
        } catch (err) {
          console.log(err);
        }
      };
      stripeToken &amp;&amp; makeRequest();
    }, [stripeToken, cart.total, history]);
  
    console.log(stripeToken);
    
    return (
      &lt;Container&gt;
        &lt;Navbar /&gt;
        &lt;Announcement /&gt;
        &lt;Wrapper&gt;
          &lt;Title&gt;YOUR BAG&lt;/Title&gt;
          &lt;Top&gt;
            &lt;TopButton&gt;CONTINUE SHOPPING&lt;/TopButton&gt;
            &lt;TopTexts&gt;
              &lt;TopText&gt;&lt;/TopText&gt;
              &lt;TopText&gt;&lt;/TopText&gt;
            &lt;/TopTexts&gt;
  
            &lt;TopButton type=&quot;filled&quot;&gt;CHECKOUT NOW&lt;/TopButton&gt;
          &lt;/Top&gt;
          &lt;Bottom&gt;
            &lt;Info&gt;
              {cart.products.map((product) =&gt; (
                &lt;Product&gt;
                  &lt;ProductDetail&gt;
                    &lt;Image src={product.img} /&gt;
                    &lt;Details&gt;
                      &lt;ProductName&gt;
                        &lt;b&gt;Product: &lt;/b&gt;
                        {product.title}
                      &lt;/ProductName&gt;
                      &lt;ProductId&gt;
                        &lt;b&gt;ID: &lt;/b&gt;
                        {product._id}
                      &lt;/ProductId&gt;
                      &lt;ProductColor color={product.color}&gt;&lt;/ProductColor&gt;
                      &lt;ProductSize&gt;
                        &lt;b&gt;Size: &lt;/b&gt;
                        {product.size}
                      &lt;/ProductSize&gt;
                    &lt;/Details&gt;
                  &lt;/ProductDetail&gt;
                  &lt;PriceDetail&gt;
                    &lt;ProductAmountContainer&gt;
                      &lt;Add /&gt;
                      &lt;ProductAmount&gt;{product.quantity}&lt;/ProductAmount&gt;
                      &lt;Remove /&gt;
                    &lt;/ProductAmountContainer&gt;
                    &lt;ProductPrice&gt;
                      Rs.{product.price * product.quantity}
                    &lt;/ProductPrice&gt;
                  &lt;/PriceDetail&gt;
                &lt;/Product&gt;
              ))}
              &lt;Hr /&gt;
            &lt;/Info&gt;
            &lt;Summary&gt;
              &lt;SummaryTitle&gt;ORDER SUMMARY&lt;/SummaryTitle&gt;
              &lt;SummaryItem&gt;
                &lt;SummaryItemText&gt;Subtotal&lt;/SummaryItemText&gt;
                &lt;SummaryItemPrice&gt;Rs.{cart.total}&lt;/SummaryItemPrice&gt;
              &lt;/SummaryItem&gt;
              &lt;SummaryItem&gt;
                &lt;SummaryItemText&gt;Estimated Shipping&lt;/SummaryItemText&gt;
                &lt;SummaryItemPrice&gt;$58&lt;/SummaryItemPrice&gt;
              &lt;/SummaryItem&gt;
              &lt;SummaryItem&gt;
                &lt;SummaryItemText&gt;Shipping Discount&lt;/SummaryItemText&gt;
                &lt;SummaryItemPrice&gt;- 48&lt;/SummaryItemPrice&gt;
              &lt;/SummaryItem&gt;
              &lt;SummaryItem type=&quot;total&quot;&gt;
                &lt;SummaryItemText&gt;Total&lt;/SummaryItemText&gt;
                &lt;SummaryItemPrice&gt;Rs.{cart.total}&lt;/SummaryItemPrice&gt;
              &lt;/SummaryItem&gt;
              &lt;StripeCheckout
                stripeKey={process.env.REACT_APP_STRIPE}
                name=&quot;Abdul Rasheed Azar&quot;
                billingAddress
                shippingAddress
                image=&quot;https://lh3.googleusercontent.com/ogw/ADea4I5yCEiXHB4_cZLjQevNUl8jMyGCJsUYPDecFVaA6Q=s83-c-mo&quot;
                description={`Your total is Rs.${cart.total}`}
                amount={cart.total * 100}
                token={onToken}
                
              &gt;
                &lt;Button&gt;CHECKOUT NOW&lt;/Button&gt;
              &lt;/StripeCheckout&gt;
            &lt;/Summary&gt;
          &lt;/Bottom&gt;
        &lt;/Wrapper&gt;
  
        &lt;Footer /&gt;
      &lt;/Container&gt;
    );
  };
  </code></pre>
  <p>`</p>