Instagram 长寿命令牌在推送到 github 时被删除

问题描述 投票:0回答:0

嗨,我正在练习使用 instagrams api,并尝试查看是否可以发布一个 github 页面网站,其中包含我帐户中的 instagram 帖子库。在本地运行时,它运行良好,但一旦将其推送到 github/已部署,当我检查我的 facebook 开发人员帐户时,令牌将被删除。有人知道怎么修这个东西吗?提前致谢!

做过的事情:

  1. 添加一个位于我的根文件夹(不是 src)中的后端,用于获取数据,如下所示:
app.get('/insta', (req, res) => {
  axios.get(`https://graph.instagram.com/me/media?fields=id,media_type,media_url,caption&limit=12&access_token=${process.env.REACT_APP_INS_TOKEN}`)
    .then((response) => {
      res.json(response.data)
    }).catch((error) => {
      console.log('error', error)
    })
})
  1. 我确保将令牌保存在一个 .env 文件中,该文件也位于我的根文件夹中。
  2. 我将 .env 添加到我的 gitignore 文件

如果有帮助,这就是我将前端连接到后端的方式

  const [feeds, setFeedsData] = useState([])
  useEffect(() => {
    const options = {
      method: 'GET',
      url: 'http://localhost:8000/insta'
    }
    async function fetchInstagramPost() {

      axios
        .request(options)
        .then((response) => {
          // console.log(response.data)
          setFeedsData(response.data)
        }).catch((error) => {
          console.log('error', error)
        })
    }
    fetchInstagramPost();
  }, [])
reactjs github-pages instagram-api
© www.soinside.com 2019 - 2024. All rights reserved.