I made a widget using the Spotify API. You can have a look at the code to see how to refresh a token. The initial query to obtain the access & refresh tokens is in the shortcut I built to simplify the process: