Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unable to set API token using token script #255

Open
agyarmati opened this issue Jun 29, 2022 · 2 comments
Open

Unable to set API token using token script #255

agyarmati opened this issue Jun 29, 2022 · 2 comments

Comments

@agyarmati
Copy link

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.

@oscb
Copy link
Contributor

oscb commented Sep 12, 2022

Which version of Typewriter are you using?

In v8 you can pipe the token as well if that helps!

@tleunen
Copy link

tleunen commented Apr 25, 2023

@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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants