Report this

What is the reason for this report?

doctl serverless connect - required API token scopes?

Posted on January 21, 2025

I have a few namespaces which host Functions based in different regions. I’d like to use doctl to switch between the different Function namespaces for easy deployment, however I’m running into an issue when I attempt to use doctl serverless connect. When running this command I receive a prompt to select the namespace I would like to connect to. After making my selection I receive the following message:

Error: GET https://api.digitalocean.com/v2/functions/namespaces/{namespace-id}: 403 You are not authorized to perform this operation

I’ve done the following troubleshooting:

  • Used doctl auth list to ensure that I was using the correct auth context
  • Created a variety of tokens with different auth scopes, init a new auth context in doctl and attempted to use doctl serverless connect again. In all situations I ensured the token had full function scope

So far I’ve only been able to successfully use this command when using an API token that has the full access scope. What are the granular scopes I can enable so I can use doctl serverless connect without requiring an API token that has full access enabled?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
0

Accepted Answer

Heya, @eldemetriou

The doctl serverless connect command requires the token to have full access to Functions. I believe currently, DigitalOcean’s granular API token scopes don’t provide a separate “read” or “limited” scope for Functions. This means that to perform operations like serverless connect, the token needs at least the Function scope.

If granular scopes for Functions do not work for this specific command:

  1. Create a separate API token with the full access scope for temporary use.
  2. Switch to this token only when running doctl serverless connect.

Steps:

doctl auth init --context functions-admin

This will allow you to switch between contexts for operations requiring broader permissions:

doctl auth switch --context functions-admin

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.