# JWT validation failed: Missing or invalid credentials

**URL:** <https://forum.api.combocurve.com/t/jwt-validation-failed-missing-or-invalid-credentials/99>\
**Category:** Guidance\
**Created:** [March 8, 2022, 7:17pm UTC](https://forum.api.combocurve.com/t/jwt-validation-failed-missing-or-invalid-credentials/99 "2022-03-08T19:17:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eduardomar](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eduardomar](https://forum.api.combocurve.com/u/eduardomar)\
**Post date:** [March 8, 2022, 7:17pm UTC](https://forum.api.combocurve.com/t/jwt-validation-failed-missing-or-invalid-credentials/99/1 "2022-03-08T19:17:41Z")

</div>

Hello,

I am getting the following message when trying to export the monthly table:

> JWT validation failed: Missing or invalid credentials

I am able to get all the other tables fine except for the monthly export one. Here is my full block code:

> #Helper method that returns an iterator with the documents from all pages  
> def get\_all(url, headers):  
> # First request  
> has\_more = True
> 
> ```
> # Keep fetching while there are more records to be returned
> while has_more:
> response = requests.get(url, headers=headers)
> 
> # Return the records to be processed by the caller instead of doing the processing here
> yield from response.json()
> 
> url = get_next_page_url(response.headers)
> has_more = url is not None
> 
> ```
> 
> def get\_records(url, auth\_headers=combocurve\_auth.get\_auth\_headers()):
> 
> ```
> df = pd.DataFrame()
> tmp_list = []
> 
> for record in get_all(url, auth_headers):
> tmp_list.append(record)
> 
> return pd.DataFrame(tmp_list).reset_index(drop=True)
> 
> ```

And executing this particular project:

> project\_id = ‘6224a9db21aea9001311d1c7’  
> url = f’[https://api.combocurve.com/v1/projects/{project\_id}/wells?take=200](https://api.combocurve.com/v1/projects/%7Bproject_id%7D/wells?take=200)’
> 
> project\_wells = get\_records(url)
> 
> url = f’[https://api.combocurve.com/v1/projects/{project\_id}/monthly-productions?take=200](https://api.combocurve.com/v1/projects/%7Bproject_id%7D/monthly-productions?take=200)’
> 
> project\_production = get\_records(url)
> 
> url = f’[https://api.combocurve.com/v1/projects/{project\_id}/scenarios?take=200](https://api.combocurve.com/v1/projects/%7Bproject_id%7D/scenarios?take=200)’
> 
> project\_scenarios = get\_records(url)  
> project\_scenarios
> 
> scenario\_id = project\_scenarios.id[0]
> 
> url = f’[https://api.combocurve.com/v1/projects/{project\_id}/scenarios/{scenario\_id}/econ-runs?take=200](https://api.combocurve.com/v1/projects/%7Bproject_id%7D/scenarios/%7Bscenario_id%7D/econ-runs?take=200)’
> 
> project\_econ\_runs = get\_records(url)
> 
> econ\_id = project\_econ\_runs.id[0]  
> econ\_id
> 
> well\_ids = list(project\_wells.id.unique())  
> well\_ids
> 
> monthly\_export\_table = pd.DataFrame()
> 
> for well\_id in well\_ids:  
> url = f’[https://api.combocurve.com/v1/projects/{project\_id}/scenarios/{scenario\_id}/econ-runs/{econ\_id}/monthly-exports/{well\_id}?skip=0&take=100](https://api.combocurve.com/v1/projects/%7Bproject_id%7D/scenarios/%7Bscenario_id%7D/econ-runs/%7Becon_id%7D/monthly-exports/%7Bwell_id%7D?skip=0&take=100)’  
> print(url)  
> monthly\_export = get\_records(url)
> 
> ```
> monthly_export_table = pd.concat([monthly_export_table,monthly_export])
> 
> ```
> 
> monthly\_table = monthly\_table.reset\_index(drop=True)

---

<div class="post-metadata">

**Author:** ![maikel.ruiz](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.api.combocurve.com/maikel.ruiz/32/101_2.png) [@maikel.ruiz](https://forum.api.combocurve.com/u/maikel.ruiz)\
**Post date:** [March 8, 2022, 8:06pm UTC](https://forum.api.combocurve.com/t/jwt-validation-failed-missing-or-invalid-credentials/99/2 "2022-03-08T20:06:00Z")

</div>

> [@eduardomar](#):
>
> `url`

Hey @eduardomar. We are taking a look at your code to see what the problem could be.

Regards

---

<div class="post-metadata">

**Author:** ![maikel.ruiz](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.api.combocurve.com/maikel.ruiz/32/101_2.png) [@maikel.ruiz](https://forum.api.combocurve.com/u/maikel.ruiz)\
**Post date:** [March 8, 2022, 8:22pm UTC](https://forum.api.combocurve.com/t/jwt-validation-failed-missing-or-invalid-credentials/99/3 "2022-03-08T20:22:03Z")

</div>

I can see something wrong in the call to the monthly exports:

The `:id` is expected to be a monthly export id, not a well id:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/the_combocurve_api/original/1X/8adb88a16dfcd0a3a65f32934a1e80606e09ad09.png)  
See more details: [ComboCurve REST API](https://docs.api.combocurve.com/#d5eb329d-6463-4b07-931d-4c9402f6041e)

As it mentions you have to create the monthly export first, using this method: [ComboCurve REST API](https://docs.api.combocurve.com/#f6545914-1f91-450f-a158-643a747e3a07)

That wouldn’t explain the authentication error you got though. I can not tell yet why you got that error, it seems you are using `get_auth_headers` correctly. But you can try fixing that ☝ first and we’ll see from there.

Also, since your helpers is handling the pagination, you don’t need to manually include `skip` param in `url`.

Regards
