【问题标题】:expo auth session spotify get refresh tokenexpo auth session spotify 获取刷新令牌
【发布时间】:2022-12-03 07:58:11
【问题描述】:

我正在尝试通过我的 expo 应用程序上的 expo-auth-session 进行 spotify 登录 在 expo-auth-session 文档中, https://docs.expo.dev/guides/authentication/#spotify

我知道授权代码流在响应中为我提供了授权代码,而隐式流在响应中为我提供了访问令牌。这两个流程都没有给我 aDoes anyone know how to get the refresh token?

我尝试使用从授权代码流中获得的授权代码调用刷新令牌端点,但它没有用。

【问题讨论】:

    标签: react-native express axios expo spotify


    【解决方案1】:

    您可以通过 curl 获取刷新令牌

    curl -d client_id={CLIENT_ID} 
    -d client_secret={CLIENT_SECRET} 
    -d grant_type=authorization_code 
    -d code={CODE} 
    -d redirect_uri={REDIRECT_URI} 
    https://accounts.spotify.com/api/token
    

    第 1 步 - 创建您的应用程序

    Spotify Developer Dashboard 中创建您的应用程序

    获取Client IDClient Secret并添加redirect URIs

    第 2 步 - 获取代码

    https://accounts.spotify.com/authorize?response_type=code&client_id={your client id}&scope=user-read-email&redirect_uri={your redirect URL, mine is http://localhost:3000}
    

    浏览器会在地址控件中显示代码,复制code部分。

    第 3 步 - 获取刷新

    从终端通过 curl 获取刷新代码

    curl -d client_id={your client it} 
    -d client_secret={your client secret} 
    -d grant_type=authorization_code 
    -d code={code from Step #2} 
    -d redirect_uri=http://localhost:3000 
    https://accounts.spotify.com/api/token | jq
    

    您可以获得刷新令牌

    {
      "access_token": "BQC...V-1"
      "token_type": "Bearer",
      "expires_in": 3600,
      "refresh_token": "AQA...6twR
      "scope": "user-read-email"
    }
    

    参考

    How to create a Spotify refresh token the easy way

    【讨论】:

      猜你喜欢
      • 2022-06-19
      • 2021-07-19
      • 2021-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-05
      • 2023-03-31
      相关资源
      最近更新 更多