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 https://developers.google.com/identity/sign-in/web/devconsole-project.
I have to restart the application to make it work again. Below are the request details.
Short Link API
https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=<key_of_my_firebase_project>
Request body (JSON)
{
"dynamicLinkInfo": {
"domainUriPrefix": "https://xxx.page.link",
"link": "https://a.very.long/link"
},
"suffix": {
"option": "UNGUESSABLE"
}
}
Response (When it works)
{
"shortLink": "https://xxx.page.link/XXXXXXXXXX",
"previewLink": "https://xxx.page.link/XXXXXXXXXX?d=1"
}
What should I do to make sure I can always get a valid short link from Firebase?