title: PayPal authentication problem on azure "live store"
body: <p>I am getting the following error when trying to use paypal API</p>
  <pre><code>HttpStatusCode: Unauthorized; AUTHENTICATION_FAILURE; Authentication failed due to invalid authentication credentials or a missing Authorization header.
  </code></pre>
  <p>But problem is only when i publish my code to Azure Api. Live store works if I run it on visual studio.</p>
  <pre><code>    public async Task&lt;bool&gt; InvoicingCreate(Models.ShopTransaction t)
      {
          sentJson = null;
          if (_accessToken == null) await GetAccessTokenAsync();
  
          HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, &quot;v2/invoicing/invoices&quot;);
          request.Headers.Authorization = new AuthenticationHeaderValue(&quot;Bearer&quot;, _accessToken.access_token);
  
          bool addNotes;
          if (t.Product.TotalPrice == 0.0) addNotes = false;
          else if (t.PaymentMethod == null) addNotes = true;
          else if (t.PaymentMethod == &quot;paypal&quot; || t.PaymentMethod == &quot;credit_card&quot;) addNotes = false;
          else addNotes = true;
  
          string billingEmail;
          if (t.Product.IndividualCouponId.HasValue)
          {
              billingEmail = _configuration[&quot;Shop:CouponInvoiceEmail&quot;];
          }
          else
          {
              billingEmail = t.BillingAddress.Email;
          }
          var inv = new Root
          {
              detail = new Detail
              {
  
          .......details the items. ...
              },
  
  
          .......Fill the items. ...
  
  
          sentJson = JsonConvert.SerializeObject(inv, Formatting.None, new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore });
  
          request.Content = new StringContent(JsonConvert.SerializeObject(inv), Encoding.UTF8, &quot;application/json&quot;);
  
          HttpResponseMessage response = await _httpClient.SendAsync(request);
  
          string content = await response.Content.ReadAsStringAsync();
  
          if (response.StatusCode != System.Net.HttpStatusCode.Created)
          {
              Error error = JsonConvert.DeserializeObject&lt;Error&gt;(content);
              throw new Exception(CompactError(&quot;Invoicing-create&quot;, response.StatusCode, error));
          }
          CreateResponse invoiceCreated = JsonConvert.DeserializeObject&lt;CreateResponse&gt;(content);
  
          t.InvoiceId = invoiceCreated.href.Split('/').Last();
  
          return true;
      }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/9Lxmr.jpg" rel="nofollow noreferrer">Auth methode</a></p>
  <p><a href="https://i.stack.imgur.com/K9zSo.jpg" rel="nofollow noreferrer">appsettings.json paypalmodel</a></p>
  <p>Invoicing methode</p>