Search code examples
sonos

Sonos auth token uses a Code that only works once


The Code that is returned from the auth endpoint can only be used once to get an access token / refresh token pair. This means it cannot be directly used with Alexa account linking, as that expects to use that code all the time. Any chance we get can a more "permanent" Code?


Solution

  • Sonos employs the Authorization Code flow of OAuth 2.0. In that flow, the auth code returned in the first step is a short-lived, one-time-use code. The Alexa dev site gives a good description of how to use this flow with Alexa skills.

    https://developer.amazon.com/blogs/post/Tx3CX1ETRZZ2NPC/Alexa-Account-Linking-5-Steps-to-Seamlessly-Link-Your-Alexa-Skill-with-Login-wit