laggingreflex
laggingreflex

Reputation: 34677

Is it possible to set access_token in netlify.toml file?

netlify command-line lets you specify the access_token either through ~/.config/.netlify or the -A switch.

However I was wondering whether it'll be accepted through the ./netlify.toml config file.

In the docs there seem to be fields that suggest it might:

[context.production]
  environment = { ACCESS_TOKEN = "super secret", NODE_ENV = "8.0.1" }

[context.deploy-preview.environment]
  ACCESS_TOKEN = "not so secret"

But when I try it gives the error "No access token found. Please login." (from debug logs)

So, is it possible to set the access_token through ./netlify.toml file, and if so what am I doing wrong?

If not, what do the ACCESS_TOKEN mentioned in the docs actually do, and how are they different from the access_token found in ~/.config/.netlify file?

Upvotes: 0

Views: 716

Answers (1)

talves
talves

Reputation: 14353

So, is it possible to set the access_token through netlify.toml file, and if so what am I doing wrong?

The netlifyctl command line sets up the access_token in a config file not an environment variable, so the ACCESS_TOKEN environment variable would not be used by the netlifyctl command at the time of this answer.

If not, what do the ACCESS_TOKEN mentioned in the docs actually do, and how are they different from the access_token found in ~/.config/netlify file?

The ACCESS_TOKEN mentioned in the docs is just an example of how to set an environment variable for use in a script or build process at the time of a deploy on netlify. These two are not one in the same and have nothing to do with each other in this case. In theory, you could use the environment variable to build a script to run the netlifyctl -A using the environment variable to pass the access token to the command.

NOTE: Do not put secret tokens into your netlify.toml file or .env files of a public repository for Netlify. In fact, be careful when using secret keys on public repositories in Netlify. These keys could be exposed by a commit or pull request by someone else or by accident. There is an explanation here of how to build a .env file to create environment variables from "Build Environment Variables" section for use in build scripts in a private repository.

Upvotes: 4

Related Questions