Import existing tokens

Hi,

I have an influxdb setup with existing tokens.
I would like to move the influx server (a complete replace) but do not want to re-distribute new tokens.
Is it possible to create tokens in influxdb with a specified token value.
I have a list of all tokens, their roles and tags in a csv file so is there is a way to create a token with a specified value via the API doing this will be trivial for me.

Any suggestions on how to do this would be very helpful.

1 Like

You could move the entire db with all the data. But it seems you don’t want to copy/move all the data.
You can recreate new authorizations with an existing token in a serveral ways:

Hi @VlastaHajek

Thanks for your response.

I use this command to make a new influxdb token (for my telegraf client which can write to a single bucket)

curl --header "Authorization: Token ${TOKEN}" 127.0.0.1:9999/api/v2/authorizations -X POST --data '{ "status": "active", "description": "description", "orgID": "ORG_ID", "userID": "USER_ID", "permissions": [ { "action": "write", "resource": { "type": "buckets", "id": "BUCKET_ID", "orgID": "ORG_ID", "org": "ORG_NAME" } } ] }'

${TOKEN} ins an environment variable which is the token main user on the influxdb server.
This command outputs a JSON document with a new (randomised) token in the .token path

If my client already has a token with value TTT configured can I make a token in influxdb with value TTT?
I can`t see any api documentation allowing me to specify the token’s value.
Is there something I can add to my josn?

Thanks,
Reshad

According to the server swagger it should be sufficient to add token field to JSON

1 Like

Hi @VlastaHajek

Here is the API call I am making to import the token (with output)

root@ip-172-31-66-227:~# curl --header "Authorization: Token ${TOKEN}" \
>     127.0.0.1:9999/api/v2/authorizations \
>     -X POST --data '{
>   "status": "active",
>   "token": "TOKENTOKENTOKENTOKEN",
>   "description": "test",
>   "orgID": "0dfc83f08cce3744",
>   "userID": "065d00dcf06ee000",
>   "permissions": [
>     {
>       "action": "write",
>       "resource": {
>         "type": "buckets",
>         "id": "1af80950e84517ad",
>         "orgID": "0dfc83f08cce3744",
>         "org": "influx"
>       }
>     }
>   ]
> }' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   944  100   586  100   358   143k  89500 --:--:-- --:--:-- --:--:--  230k
{
  "id": "065d0e3668ad4000",
  "token": "RE0FQR2LnuT0qh9ODwCwBmjGUTAaHVcVxabRM-QDFrhypXVO98qXDKgRTjwOUO7ugT2-CdK0GXy8QYrwCpoWvQ==",
  "status": "active",
  "description": "test",
  "orgID": "0dfc83f08cce3744",
  "org": "influx",
  "userID": "065d00dcf06ee000",
  "user": "influx",
  "permissions": [
    {
      "action": "write",
      "resource": {
        "type": "buckets",
        "id": "1af80950e84517ad",
        "orgID": "0dfc83f08cce3744",
        "name": "influx",
        "org": "influx"
      }
    }
  ],
  "links": {
    "self": "/api/v2/authorizations/065d0e3668ad4000",
    "user": "/api/v2/users/065d00dcf06ee000"
  },
  "createdAt": "2020-09-25T07:47:45.186188858Z",
  "updatedAt": "2020-09-25T07:47:45.186188858Z"
}
root@ip-172-31-66-227:~# 

I pass TOKENTOKENTOKENTOKEN as the input and get a new token created RE0FQR2LnuT0qh9ODwCwBmjGUTAaHVcVxabRM-QDFrhypXVO98qXDKgRTjwOUO7ugT2-CdK0GXy8QYrwCpoWvQ==

Any ideas would be really helpful.
Thanks,
Reshad

1 Like

I’m sorry, I had misled you. I thought this should work, but looking at the server sources the token is not copied from the request.
Feel free to create an issue for this.

Hey,

i know its an old post but is there any solution? that would be great!!

Thanks