This is a simple tool to get a Maskinporten token or Altinn token.
Use the install script for MacOS named install_mac.sh
to install the tool. Below are some manual steps to install the tool if that is preferred.
For ARM 64
dotnet publish -c Release -r osx-arm64 --self-contained --output ~/.token-getter
For x64
dotnet publish -c Release -r osx-x64 --self-contained --output ~/.token-getter
Then create a symlink to the executable in the path
sudo ln -s ~/.token-getter/token-getter /usr/local/bin/token-getter
chmod +x /usr/local/bin/token-getter
Use the install script for windows named install_windows.bat
to install the tool. Below are some manual steps to install the tool if that is preferred.
Terminal must be run as administrator for the following steps
mkdir "C:\Program Files\token-getter"
For x64
dotnet publish -c Release -r win-x64 --self-contained
xcopy .\bin\Release\net8.0\win-x64 "C:\Program Files\token-getter" /E /I /H
For x86
dotnet publish -c Release -r win-x86 --self-contained
xcopy .\bin\Release\net8.0\win-x86 "C:\Program Files\token-getter" /E /I /H
setx /M PATH "%PATH%;C:\Program Files\token-getter"
Check the help for the tool by running the following command
token-getter --help
To generate a token, run the following command
token-getter generate -c <credentials-set> -s <scopes> -t <type> -e <environment>
Use token-getter generate --help
to get more information about the command.
Example:
token-getter generate -c tt02_ae_so -t altinn -e test -s altinn:serviceowner altinn:events.publish
The tool provides a way of setting up multiple sets of credentials through the commands:
token-getter credentials add <name>
token-getter credentials list
token-getter credentials remove <name>