【问题标题】:Spotify api refresh token return error 400Spotify api 刷新令牌返回错误 400
【发布时间】:2020-09-14 00:23:54
【问题描述】:

我尝试刷新 Spotify 令牌,但服务器返回 400 错误。 我使用 angularjs 和打字稿

let httpParams = new HttpParams()
  .append("grant_type", "refresh_token")
  .append("refresh_token", token)
  .append("client_id", my_client_id);

  this.http.post("https://accounts.spotify.com/api/token", httpParams.toString(), 
  { headers: { 
    'Content-Type':'application/x-www-form-urlencoded'
  },}).subscribe(data => {  
    console.log(data['access_token'])
  })

这是错误:

【问题讨论】:

    标签: javascript angular typescript ionic-framework spotify


    【解决方案1】:

    您是否确保在 .append("refresh_token", token) 中作为参数传递的令牌是 API 最初提供的刷新令牌而不是访问令牌?根据参数名称,您可能会传递初始 access_token,这将导致 status:400 错误。

    通过Authorization Flow 的初始请求将为您提供两者。请确保在您请求新的刷新令牌时提供此时收到的刷新令牌,它应该可以工作。

    【讨论】:

      猜你喜欢
      • 2022-07-15
      • 2023-02-02
      • 2021-10-11
      • 2019-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-25
      • 2020-05-15
      相关资源
      最近更新 更多