客户机密和ID将在未来几个月内弃用

问题描述

我的代码有效,但请求格式将在未来几个月内弃用。

建议使用Github

的新格式
curl -u my_client_id:my_client_secret https://api.github.com/users/user

在接下来的几个月中,有人可以向我展示重新格式化它的正确方法吗?我已经尝试了一切。这是我尝试过的一个示例:

我的尝试无效

`-u ${this.client_id}:${this.client_secret} https://api.github.com/users/${user}`

我当前的代码

class Github {
  constructor() {
    // THESE ARE FAKE!!!
    this.client_id = 'a71344259aec03d0cea3';
    this.client_secret = 'a28202377336e199cb554bd099e6e5fe672788db';
    this.repos_count = 7;
    this.repos_sort = 'created: asc';
  }

  async getUser(user) {
    const profileResponse = await fetch(
      `https://api.github.com/users/${user}?client_id=${this.client_id}&client_secret=${this.client_secret}`
    );

    const repoResponse = await fetch(
      `https://api.github.com/users/${user}/repos?per_page=${this.repos_count}&sort=${this.repos_sort}&client_id=${this.client_id}&client_secret=${this.client_secret}`
    );
    console.log(user);

    const profile = await profileResponse.json();
    const repos = await repoResponse.json();

    return {
      profile,repos,};
  }
}

解决方法

mongoose.connection.close()中的-u选项使用HTTP Basic authentication

这是使用curl字符串,对它进行base64编码(例如user:password => user:password),然后像这样将其添加到dXNlcjpwYXNzd29yZA==请求标头中

Authorization

使用Authorization: Basic dXNlcjpwYXNzd29yZA== 时,您必须使用类似btoa()的方式手动完成此操作

fetch

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...