Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(firebase functions) Error: Forbidden Your client does not have permission to get URL /

I have problem when invoking deployed function in firebase. I have an editor role in the firebase project and when I deployed functions, didn't have any problem with invoking them. When I deployed a new function yesterday, I got the error message that says

Error: Forbidden

Your client does not have permission to get URL / < Function Name > from this server.

Nothing has been changed to my role. It is strange that since yesterday, whatever function I deployed, threw those errors.

In gcp console/cloud functions, where you can see permissions of the function that was selected, I've noticed that "cloud functions invoker" was not assigned to that function. I thought this should be added to any function by default as long as I have an editor access but strangely it does not add them anymore. other functions that were deployed since yesterday have the same issue

any suggestions or advices will be appreciated. Thank you

like image 523
M.K. Kim Avatar asked Apr 03 '20 19:04

M.K. Kim


People also ask

How do you debug a firebase function WebStorm?

From the main WebStorm menu, you can now select Run | Debug... and select your new configuration. WebStorm will attach to the process hosting your functions, and you can use debug features (breakpoints, etc.) just like a normal debug session from within WebStorm.

Why does cloud deployment fail?

Cloud Functions deployment can fail if the entry point to your code, that is, the exported function name, is not specified correctly. Your source code must contain an entry point function that has been correctly specified in your deployment, either via Cloud console or Cloud SDK.


4 Answers

Unfortunately, you can't do this in Firebase, you have to go into the Google Cloud project which 'hosts' your firebase project. You can follow this guide by Google, and have a look at the screenshots below:

enter image description here

You should see Allow unauthenticated now

enter image description here

like image 160
Ben Butterworth Avatar answered Oct 20 '22 10:10

Ben Butterworth


So here's the answer from the firebase team

The issue you are experiencing is likely caused by the fact that after January 15, 2020, Google Cloud Functions automatically creates HTTP functions to be >private by default.

Please, update the CLI, by running the following command:

npm install -g firebase-tools

This will ensure that future HTTP functions that are created will be publicly accessible.

Lastly, for the existing functions that has the permission issues, you will need >to manually set a function to public using Cloud Console or gcloud CLI.

If you have any questions or you are still facing this issue, please, don’t >hesitate to write back.

edited* There could be several reasons to cause this issue.

  1. check your function endpoint url make sure there's no typo or space
  2. In the gcp console, make sure you have permission to invoke function https://console.cloud.google.com/functions/list?project=<YOUR_PROJECT_ID>
  3. If the above two are checked, delete your function and redeploy your them again
like image 31
M.K. Kim Avatar answered Oct 20 '22 08:10

M.K. Kim


  • Please Review Allowing unauthenticated function invocation

As of January 15, 2020, HTTP functions require authentication by default. You can specify whether a function allows unauthenticated invocation at or after deployment.

like image 8
Chintan Mehta Avatar answered Oct 20 '22 09:10

Chintan Mehta


To allow unauthenticated invocation of a function, you add the special allUsers member id to the function and grant it the Cloud Functions Invoker role:

enter image description here

You can limit domain access in your function, for example:

exports.myTest= async(req, res) => {
  res.set('Access-Control-Allow-Origin', 'foo.com');
  ...etc 
like image 2
smoore4 Avatar answered Oct 20 '22 08:10

smoore4