How to Change v2 App Key

As per this section of the migration guide:

The recommended practice is to change the AppKey in The Things Network V2.

I’m poking around in the v2 ttn console and I feel like a bit of a dunce as I can’t find where or how to change the app key for my devices. Also, do I have to do this for each device individually or is there a script I can run to do this en masse for all the devices in my application?

Found it under:

Applications > my application id > Devices > some device id > Settings

Still would rather not have to click through hundreds of devices to do this if there’s a less Byzantine approach… anyone know? I guess I could see what the console does in dev-tools and write a NodeJS script…

Or use the ttn-lw-migrate tool

I didn’t realize the ttn-lw-migrate tool could do that… the help certainly doesn’t suggest that it can:

Available Commands:
  application Export all devices of an application
  device      Export devices by DevEUI
  help        Help about any command
  sources     List available sources
  version     Print version information

      --dev-id-prefix string         (optional) value to be prefixed to the resulting device IDs
      --dry-run                      Do everything except resetting root and session keys of exported devices
      --frequency-plans-url string   URL for fetching frequency plans (default "")
  -h, --help                         help for ttn-lw-migrate
      --verbose                      Verbose output

Use "ttn-lw-migrate [command] --help" for more information about a command.

Anyway, I got it done with a simple-enough node script, copied my cookie and authorization headers out of dev tools in Chrome and ran this (using the devices I exported using the ttn-lw-migrate tool). Basically just a PATCH to{app_id}/devices/{dev_id} with a body that looks like this:

      app_key: 'randomly-generated-appkey',
      disable_fcnt_check: false,
      method: 'OTAA',
      uses_32bit_fcnt: false

Seems like it worked, so I think I’m ok.


The docs do:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.