Why am I getting "signature is invalid (Code = 40110000)" error?

With my oAuth access token with live trading, the following call succeeds:

GET https://api.alpaca.markets/v2/positions/MSFT

However the following call fails:

GET https://data.alpaca.markets/v1/last/stocks/MSFT

with error: signature is invalid (Code = 40110000)

It has been working for a week or so, then it started producing above error. Thought there might be a problem with the access token. So I regenerated one. Still getting the same error.

What does this error actually mean?

This morning it (data.alpaca.markets) started throwing this error:


403 Forbidden

403 Forbidden



nginx


Yes, I got this message too few time on paper account

I think these errors are because two certificates are presented, one of which is invalid (CN=Kubernetes Ingress Controller Fake Certificate).

Today, the alpaca support responded to my email regarding this error. They fixed the issue and it is now working for me.

This has randomly happened to me, but it appears to be related to the /bars/ endpoint:

Traceback (most recent call last):

File “/usr/local/lib/python3.8/site-packages/alpaca_trade_api/rest.py”, line 140, in _one_request

resp.raise_for_status()

File “/usr/local/lib/python3.8/site-packages/requests/models.py”, line 940, in raise_for_status

raise HTTPError(http_error_msg, response=self)

requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://data.alpaca.markets/v1/bars/day?symbols=TLRY%2CSPWR%2CMP%2CMARA%2CGME&limit=20

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File “/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py”, line 34, in inner

response = get_response(request)

File “/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py”, line 115, in _get_response

response = self.process_exception_by_middleware(e, request)

File “/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py”, line 113, in _get_response

response = wrapped_callback(request, *callback_args, **callback_kwargs)

File “/usr/local/lib/python3.8/site-packages/django/utils/decorators.py”, line 142, in _wrapped_view

response = view_func(request, *args, **kwargs)

File “/usr/local/lib/python3.8/site-packages/django/contrib/auth/decorators.py”, line 21, in _wrapped_view

return view_func(request, *args, **kwargs)

File “/ap/alpaca/views.py”, line 223, in positions

bars = api_test.get_barset(sym_list, ‘day’, 20)

File “/usr/local/lib/python3.8/site-packages/alpaca_trade_api/rest.py”, line 456, in get_barset

resp = self.data_get(’/bars/{}’.format(timeframe), params)

File “/usr/local/lib/python3.8/site-packages/alpaca_trade_api/rest.py”, line 172, in data_get

return self._request(

File “/usr/local/lib/python3.8/site-packages/alpaca_trade_api/rest.py”, line 119, in _request

return self._one_request(method, url, opts, retry)

File “/usr/local/lib/python3.8/site-packages/alpaca_trade_api/rest.py”, line 148, in _one_request

raise APIError(error, http_error)

alpaca_trade_api.rest.APIError: token is not authorized for this scope (Code = 40110000)