首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Spotify API进行授权

使用Spotify API进行授权
EN

Stack Overflow用户
提问于 2020-06-17 12:45:24
回答 1查看 53关注 0票数 0

我已经通过Spotify在我的项目上设置了授权,它在本地工作,并且在我的Heroku临时环境中工作,但不在我的Heroku生产环境中工作。它要么超时,要么留在空白页上。我曾经能够通过Facebook将其转到Spotify登录,但在提交时超时。不知道这可能是什么原因,想知道是不是因为应用程序中添加了自定义域。

代码语言:javascript
复制
   onSuccess = (response, mutation) => {
     this.setState({error: false, loading: true})
     mutation({
       variables: { accessToken: response.access_token}
     })
     .then((res) => {
       this.setState({loading: false})
       this.props.history.push(`/`)
       window.location.reload();
     })
     .catch((error) => {
       this.setState({loading: false})
       this.setState({error: true, errorMsg: "Something went wrong, please try again"})
     })
   }

  onFailure = (response) => {
    this.setState({click: false, error: true, errorMsg: "Something went wrong, please try again"})
  }
   
   
   
   <SpotifyLogin
      clientId={process.env.REACT_APP_SPOTIFY_ID}
      onClick={() => this.setState({click: true})}
      redirectUri={process.env.REACT_APP_SPOTIFY_URL || "http://localhost:3000/"}
      onSuccess={(data) => this.onSuccess(data, mutation)}
      onFailure={this.onFailure}
      scope="user-read-private user-top-read user-read-email user-read-playback-state"
      className="onboarding__spotify-cta"
    />

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-17 21:39:46

如果问题不是在你的开发环境中,而是在你的prod中,那是因为你的重定向uri有问题,检查你的process.env.REACT_APP_SPOTIFY_URL是否正确

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62421652

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档