Get a Refresh Token

Your Raspberry Pi now has the AVS Device SDK installed and your credentials loaded, but your device still needs a refresh token to enable your client to maintain a connection to the Alexa Voice Service in the cloud. If you design an Alexa Built-in product and ship a million of them to your customers, they can all use the same Client ID and ProductID - but each individual device will require a unique refresh token to authenticate with AVS through Login With Amazon (LWA).

Normally, your customer would get a refresh token delivered when they activate your (their) device using a companion app, companion site, or code-based linking (CBL). For this tutorial, you'll be both the device maker and the customer - using the script to launch the Sample App and request a refresh token for your prototype device.

Terminal window

In a terminal window, navigate to the /home/pi directory and run the script:

cd /home/pi/
sudo bash

Once the App starts, startup debug messages will start scrolling through the window rapidly, and you'll see a notification that your device is checking for Authorization. Look for the box with the URL and the code you need to authenticate your device:


Using any internet-connected device (for example, your phone), go to to log in with your Amazon developer credentials and input the code provided by your sample app. It might take up to 30 seconds for CBLAuthDelegate to successfully get a refresh token from Login With Amazon (LWA). You'll get a success message, and your sample app should be ready to go!

Your hard work has paid off, and now it's time to Talk with Alexa!