typewriter
typewriter copied to clipboard
Unable to set API token using token script
Hi! 👋
I have a Node.js project where I'm using typewriter and I'd like to set the API key from a .env
file (or any other local file that I can keep out of version control).
According to the docs on API token configuration:
Segment recommends you use a Token Script to share an API token with your team. When you use a token script, you can supply your API token as an environment variable (echo $TYPEWRITER_TOKEN), from a .env. file (source .env; echo $TYPEWRITER_TOKEN) or using any other CLI tool for providing secrets.
I've added the following to typewriter.yml
:
scripts:
token: source .env; echo $TYPEWRITER_TOKEN
I have a .env
file with TYPEWRITER_TOKEN
set at the root of the project at the same location as typewriter.yml
. However, when running npx typewriter
I get:
No valid API token, using local copy instead.
It's unclear to me from the documentation where npx typewriter
looks for the .env
file. I've also tried setting TYPEWRITER_TOKEN
in ~/.typewriter
but that didn't work either.
Which version of Typewriter are you using?
In v8 you can pipe the token as well if that helps!
@oscb Are you sure it's available through v8? I know the documentation also says that, but I can't make it work without using the token script.
echo something | npx typewriter
› Warning: No API token found at ./. Using local copy of tracking plans instead.
Running it in debug shows it still has the token though.
typewriter:config Selecting Token {
token: 'xxxx',
method: 'pipe',
isValid: true,
}
typewriter:config getToken { method: 'pipe' } +0ms
typewriter:config getToken { method: 'script' } +1ms
typewriter:config getToken { method: 'file' } +0ms
› Warning: No API token found at ./. Using local copy of tracking plans instead.