I'm a beginner in this topic, and I want to test my Cloud Function from the command line (with curl), but it keeps returning "401 Unauthorized"
I have assigned different roles to both my own account and the service account:
My account: Owner, Cloud Functions Admin, Service Account User (I’m not sure if the last one is necessary)
Service account: Service Account Token Creator (I think more roles are needed)
(By the way, for another function I selected "Allow unauthenticated invocations" and the same Service Account, but I still get the "401 Unauthorized" message when testing.)
Could someone help me get the authentication working? I've been trying for hours, but I keep getting the "401 Unauthorized" message.
Hi @NSzabolcs,
Welcome to Google Cloud Community!
The error 401 message occurs when the user is not authenticated properly. This might be due to a misconfigurations in IAM permissions, authentication token generation, or the understanding of unauthenticated function access.You may need to make sure the service account you're using has the correct permissions to actually invoke the Cloud Function, and that we're presenting the right credentials. You can follow these steps to help you resolve the problem:
If the steps did not work, you may contact Google Cloud Support. They can investigate your specific project and account for any underlying issues. When contacting them, please provide detailed information.
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.