I am uploading images to firebase storage and would like to save their images as the photoURL in Firebase authentication. However when I go to upload the image URL after using get signed URL I receive the error
Error: The photoURL field must be a valid URL.
I know that the URL is valid as I have checked it from the console out put. I have tried using decodeURI and even gone so far as to look into the source code for the firebase-admin-node
tracking all the way down to a file called auth-api-requests.ts which on line 252 checks the URL in a function named validator.isURL(request.photoUrl)
this led me to the file where the function is defined validator.ts which defines .isURL()
on line 152 in this function checks are performed against a string of forbidden characters. I dont want to tamper with the Firebase source code, but I am unable to find any solution. There should be an easier solution for the return from one google function .getSignedURL()
to be used as a parameter in another .updateUser({photoURL:
}) especially considering that one can no longer call on firebase.getDownloadURL()
from the google cloud functions node. Thank you for any assistance you provide in solving this.
var downloadURL = "";
await admin.storage().bucket("gs://****firebase.appspot.com").file(storageRef).getSignedUrl({"action":"read","expires":Date.now() + 500*365*24*3600000}).then((value) => {
console.log("value after requesting signed URL: " + JSON.stringify(value));
downloadURL = value;
return value;
}).catch((error) => {
console.log("error perfoming signed URL: " + error);
return error;
})
const url = decodeURI(downloadURL)
console.log("\nThe decodeURI url: " + url + "\n");
await admin.auth().updateUser(userID,{photoURL:url}).then((user) => {
console.log("User update ran a success: " + JSON.stringify(user));
return true;
}).catch((error) => {
console.log("An error occured in getting the user: " + error);
return error;
});