Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Using Personal Access Tokens

Use cases involving the automation of the interaction with the NAPPTIVE Playground such as CI integrations, or executions triggered by scripts are not possible with OAuth authentication mechanisms as there is no possibility to open a window browser, nor is there a user that can answer the OAuth challenge.

Personal Access Tokens (PAT) represent an alternative method to authenticate against the NAPPTIVE Playground using a programmatic approach with HTTP requests. A user account can have several PAT associated to it.

Personal Access Token from CLI

Pre-requirements

  • Playground tools are installed (kubectl & playground)
  • A valid NAPPTIVE Playground account
playground login
Login success

Creating a Personal Access Token (PAT)

To generate a new token you can use the CLI with the following command:

playground user pat create ci_pat
NAME      TOKEN
ci_pat    <your token>

Please store this value safely as it cannot be retrieved once generated. To login with this value, set the environment variable PLAYGROUND_PAT with the token, or save it to a file. Use 'playground login --pat' to log into the NAPPTIVE Playground without OAuth.

Alternatively, you can store the contents of the generated pat with:

playground user pat create test_pat --patFile /tmp/test_pat.dat
You can use this Personal Access Token to log into the NAPPTIVE Playground using the following command:

$ playground login --patFile /tmp/test_pat.dat

Using the Personal Access Token (PAT)

There are two methods to use PAT. First, you can set the environment variable PLAYGROUND_PAT with the contents of the token, and execute:

playground login --pat
Login success

Alternatively, you can load the PAT from a file using:

playground login --patFile /tmp/test_pat.dat
Login success

After this, you can interact normally with the NAPPTIVE Playground using the playground CLI.

Listing Personal Access Tokens (PAT)

To list the tokens associated with your user account and check when they were last used, execute:

playground user pat list
NAME        LAST_LOGIN
ci_pat      2021-04-06 18:16:28 +0200 CEST
test_pat    2021-04-06 18:18:19 +0200 CEST

Removing/Revoking a Personal Access Token (PAT)

To remove/revoke a Personal Access Token use:

playground user pat delete mypat
STATUS     INFO
SUCCESS    Removed

Note that this operation removes the token from the system. Sessions that have already been negotiated using this token will not be invalidated.

Personal Access Token from the Web

From the playground we can create, list and delete Personal Access Tokens. This will allow us to create and manage the PAT from machines in which we do not have the CLI installed, only we will need a browser.

Click on the icon User on the lower side of the left-hand screen to access your user info. And in the User modal window click on the PATs(Personal Access Token) tab

Personal Access Token

For more information about the web usage of Personal access tokens, check the Personal Access Token Management from WebUI section.

FAQ

Invalid character U looking for beginning value

$ playground login --pat
invalid character 'U' looking for beginning of value

This is usually related with the value of PLAYGROUND_PAT a likely cause by the terminal copy & paste settings. Make sure no trailing newline characters (\n) are included at the end.

What’s next

  • Check our deploy tutorials on the different methods to deploy applications.
  • Clone our cd-example repository and discover how you can integrate a QA pipeline with the NAPPTIVE Playground.