Node returns Invalid API Token error

Installed a node on macOS Big Sur 11.4 (Intel). Node is sync’d and up and running. Any command line goal command returns an error: {“message”:“Invalid API Token”}

curl -X GET http://$(cat $ALGORAND_DATA/ -H “X-Algo-API-Token: $(cat $ALGORAND_DATA/algod.token)”

I’ve tried reinstalling, requesting a new token with no luck.

Tried a few examples from this tutorial all with the same error.

Are you sure you used the same data folder for both the time you started the node and the time you run the goal command?

Can you run the following:

goal node stop
goal node start
goal version -v
goal node status

The node was successfully stopped.
~ % goal node start
Algorand node successfully started!
~ % goal version -v
Version: [v1 v2]
GenesisID: mainnet-v1.0
Build: 2.7.1.stable [rel/stable] (commit #5e00bcd6+)
~ % goal node status
Last committed block: 14911471
Time since last block: 3.1s
Sync Time: 18.5s
Last consensus protocol: GitHub - algorandfoundation/specs at 65b4ab3266c52c56a0fa7d591754887d68faad0a
Next consensus protocol: GitHub - algorandfoundation/specs at 65b4ab3266c52c56a0fa7d591754887d68faad0a
Round for next consensus protocol: 14911472
Next consensus protocol supported: true
Last Catchpoint:
Genesis ID: mainnet-v1.0
Genesis hash: wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=
~ %

I think my $ALGORAND_DATA is misconfigured or not pointing to the correct location. When I substitute “$(cat $ALGORAND_DATA)” for “$(cat ~/node/data/” I get valid responses.

Yes, I think the issue is most likely that you are using two different $ALGORAND_DATA.

You can check the value of it via echo $ALGORAND_DATA in all the terminals to be sure.

Is this a node installation issue or a shell environment issue?

What is your $ALGORAND_DATA pointing to? This seems like a env issue.

Thank you for the insights, helped me resolve the issue. I had 2 separate things going on, macOS prompted me to change the default shell in the midst of installation and probably needed a reboot to update my /.zshrc file correctly. Secondly, the node setup tutorial I was using to debug my node has some bad characters in the sample code (smart quote parentheses) that zsh didn’t like and also caused invalid token error on the goal commands on zsh on macOS.