检索访问令牌Reddit API

时间:2018-10-09 09:52:36

标签: javascript reactjs fetch reddit

我正在查看reddit api,并按照指南获取access_token-see here

我的代码如下:

componentDidMount() {

  const code = '12345';
  let headers = new Headers();
  headers.set('Authorization', 'Basic ' + (CLIENT_ID + ":" + CLIENT_SECRET));

    fetch('https://www.reddit.com/api/v1/access_token', {
      method: 'post',
      headers,
      body: JSON.stringify({
        grant_type: 'authorization_code',
        code,
        redirect_uri: 'http://localhost:3000'
      })
    });
  }
}

这将返回401错误,如果我删除标头,它将卡在200 OPTIONS上。

有人能看到我在做什么吗?

0 个答案:

没有答案
相关问题