Firebase Dynamic Links Short Links API Returning 401

I'm using Firebase dynamic links short links API to shorten URLs in a Nuxt.js application. When I try to send a request to the API using Axios, it works and returns 200 when the application is initially started, but after some time (maybe a day or so), it starts returning 401 with the following response.

Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See

I have to restart the application to make it work again. Below are the request details.

Short Link API<key_of_my_firebase_project>

Request body (JSON)

    "dynamicLinkInfo": {
        "domainUriPrefix": "",
        "link": "https://a.very.long/link"
    "suffix": {
        "option": "UNGUESSABLE"

Response (When it works)

    "shortLink": "",
    "previewLink": ""

What should I do to make sure I can always get a valid short link from Firebase?