Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 曾经返回Git安装访问令牌的代码不再返回_Javascript_Node.js_Authentication_Github_Github Api - Fatal编程技术网

Javascript 曾经返回Git安装访问令牌的代码不再返回

Javascript 曾经返回Git安装访问令牌的代码不再返回,javascript,node.js,authentication,github,github-api,Javascript,Node.js,Authentication,Github,Github Api,不久前,我回答了一个问题。代码示例是我在几个应用程序中使用过的,没有任何问题 现在,我正尝试再次使用它,但运行时出现以下错误: TypeError:无法读取未定义的属性“access\u tokens\u url” 您可以看到,access\u tokens\u url不在响应中: { status: 200, statusText: 'OK', headers: { server: 'GitHub.com', date: 'Tue, 13 Nov 2018 19:48

不久前,我回答了一个问题。代码示例是我在几个应用程序中使用过的,没有任何问题

现在,我正尝试再次使用它,但运行时出现以下错误:

TypeError:无法读取未定义的属性“access\u tokens\u url”

您可以看到,
access\u tokens\u url
不在响应中:

{ status: 200,
  statusText: 'OK',
  headers: 
   { server: 'GitHub.com',
     date: 'Tue, 13 Nov 2018 19:48:12 GMT',
     'content-type': 'application/json; charset=utf-8',
     'content-length': '2',
     connection: 'close',
     status: '200 OK',
     'cache-control': 'public, max-age=60, s-maxage=60',
     vary: 'Accept',
     etag: '"5b49dc572fac1de90f6dcbe96af712d9"',
     'x-github-media-type': 'github.machine-man-preview; format=json',
     'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type',
     'access-control-allow-origin': '*',
     'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
     'x-frame-options': 'deny',
     'x-content-type-options': 'nosniff',
     'x-xss-protection': '1; mode=block',
     'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
     'content-security-policy': 'default-src \'none\'',
     'x-github-request-id': 'F6A0:223A:3E7AF15:7F929C0:5BEB2A7B' },
  config: 
   { adapter: [Function: httpAdapter],
     transformRequest: { '0': [Function: transformRequest] },
     transformResponse: { '0': [Function: transformResponse] },
     timeout: 0,
     xsrfCookieName: 'XSRF-TOKEN',
     xsrfHeaderName: 'X-XSRF-TOKEN',
     maxContentLength: -1,
     validateStatus: [Function: validateStatus],
     headers: 
      { Accept: 'application/vnd.github.machine-man-preview+json',
        Authorization: 'Bearer blablabla',
        'User-Agent': 'axios/0.18.0' },
     method: 'get',
     url: 'https://api.github.com/app/installations',
     data: undefined },
  request: 
   ClientRequest {
     domain: null,
     _events: 
      { socket: [Function],
        abort: [Function],
        aborted: [Function],
        error: [Function],
        timeout: [Function],
        prefinish: [Function: requestOnPrefinish] },
     _eventsCount: 6,
     _maxListeners: undefined,
     output: [],
     outputEncodings: [],
     outputCallbacks: [],
     outputSize: 0,
     writable: true,
     _last: true,
     upgrading: false,
     chunkedEncoding: false,
     shouldKeepAlive: false,
     useChunkedEncodingByDefault: false,
     sendDate: false,
     _removedConnection: false,
     _removedContLen: false,
     _removedTE: false,
     _contentLength: 0,
     _hasBody: true,
     _trailer: '',
     finished: true,
     _headerSent: true,
     socket: 
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: null,
        npnProtocol: undefined,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 9,
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'api.github.com',
        _readableState: [Object],
        readable: false,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        _bytesDispatched: 626,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: null,
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1,
        [Symbol(asyncId)]: 24,
        [Symbol(bytesRead)]: 937 },
     connection: 
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: null,
        npnProtocol: undefined,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 9,
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'api.github.com',
        _readableState: [Object],
        readable: false,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        _bytesDispatched: 626,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: null,
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1,
        [Symbol(asyncId)]: 24,
        [Symbol(bytesRead)]: 937 },
        _header: 'GET /app/installations HTTP/1.1\r\nAccept: application/vnd.github.machine-man-preview+json\r\nAuthorization: Bearer blablabla\r\nUser-Agent: axios/0.18.0\r\nHost: api.github.com\r\nConnection: close\r\n\r\n',
     _onPendingData: [Function: noopPendingOutput],
     agent: 
      Agent {
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        defaultPort: 443,
        protocol: 'https:',
        options: [Object],
        requests: {},
        sockets: [Object],
        freeSockets: {},
        keepAliveMsecs: 1000,
        keepAlive: false,
        maxSockets: Infinity,
        maxFreeSockets: 256,
        maxCachedSessions: 100,
        _sessionCache: [Object] },
     socketPath: undefined,
     timeout: undefined,
     method: 'GET',
     path: '/app/installations',
     _ended: true,
     res: 
      IncomingMessage {
        _readableState: [Object],
        readable: false,
        domain: null,
        _events: [Object],
        _eventsCount: 3,
        _maxListeners: undefined,
        socket: [Object],
        connection: [Object],
        httpVersionMajor: 1,
        httpVersionMinor: 1,
        httpVersion: '1.1',
        complete: true,
        headers: [Object],
        rawHeaders: [Array],
        trailers: {},
        rawTrailers: [],
        upgrade: false,
        url: '',
        method: null,
        statusCode: 200,
        statusMessage: 'OK',
        client: [Object],
        _consuming: true,
        _dumped: false,
        req: [Circular],
        responseUrl: 'https://api.github.com/app/installations',
        redirects: [],
        read: [Function] },
     aborted: undefined,
     timeoutCb: null,
     upgradeOrConnect: false,
     parser: null,
     maxHeadersCount: null,
     _redirectable: 
      Writable {
        _writableState: [Object],
        writable: true,
        domain: null,
        _events: [Object],
        _eventsCount: 2,
        _maxListeners: undefined,
        _options: [Object],
        _redirectCount: 0,
        _redirects: [],
        _requestBodyLength: 0,
        _requestBodyBuffers: [],
        _onNativeResponse: [Function],
        _currentRequest: [Circular],
        _currentUrl: 'https://api.github.com/app/installations' },
     [Symbol(outHeadersKey)]: 
      { accept: [Array],
        authorization: [Array],
        'user-agent': [Array],
        host: [Array] } },
  data: [] }
我试图找出我的代码中是否有任何不同之处,但我看不到任何东西。APII是否有可能发生变化?如果有,我如何解决这个问题

其他信息。 此curl命令:

curl -i -H "Authorization: Bearer blablabla" -H "Accept: application/vnd.github.machine-man-preview+json" https://api.github.com/app/installations
还应返回数据响应,但我得到:

HTTP/1.1 200 OK
Server: GitHub.com
Date: Wed, 14 Nov 2018 20:43:04 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 5
Status: 200 OK
Cache-Control: public, max-age=60, s-maxage=60
Vary: Accept
ETag: "5b49dc572fac1de90f6dcbe96af712d9"
X-GitHub-Media-Type: github.machine-man-preview; format=json
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31536000; includeSubdomains;  preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Content-Security-Policy: default-src 'none'
X-GitHub-Request-Id: E867:223A:47CF7F2:924E87D:5BEC88D8

[

]
所以我不认为这是我的密码

在我看来,GitHub或者我配置GitHub应用程序的方式都有一个选项。一个想法

附加信息2

可能更进一步!我注意到GitHub ap没有安装,所以我现在已经安装了。我现在遇到的问题是,当我执行我的程序时,我会得到以下结果:

Unable to authenticate
附加信息3

我重新生成了我的PEM钥匙。现在我明白了:

{ HttpError: {"message":"Validation Failed","errors":[{"message":"The listed users and repositories cannot be searched either because the resources do not exist or you do not have permission to view them.","resource":"Search","field":"q","code":"invalid"}],"documentation_url":"https://developer.github.com/v3/search/"}
    at response.text.then.message (/Users/me/git/issue-tracker/node_modules/@octokit/rest/lib/request/request.js:72:19)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  name: 'HttpError',
  code: 422,
  status: undefined,
  headers: 
   { 'access-control-allow-origin': '*',
 'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type',
     'cache-control': 'no-cache',
     connection: 'close',
     'content-length': '306',
     'content-security-policy': 'default-src \'none\'',
     'content-type': 'application/json; charset=utf-8',
     date: 'Thu, 15 Nov 2018 21:14:49 GMT',
     'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
     server: 'GitHub.com',
     status: '422 Unprocessable Entity',
     'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
     'x-content-type-options': 'nosniff',
     'x-frame-options': 'deny',
     'x-github-media-type': 'github.v3; format=json, github.machine-man-preview; format=json',
     'x-github-request-id': 'DA17:447A:93639E1:1128EFAD:5BEDE1C8',
     'x-ratelimit-limit': '30',
     'x-ratelimit-remaining': '25',
     'x-ratelimit-reset': '1542316508',
     'x-xss-protection': '1; mode=block' } }
{ HttpError: {"message":"Validation Failed","errors":[{"message":"The listed users and repositories cannot be searched either because the resources do not exist or you do not have permission to view them.","resource":"Search","field":"q","code":"invalid"}],"documentation_url":"https://developer.github.com/v3/search/"}
    at response.text.then.message (/Users/me/git/issue-tracker/node_modules/@octokit/rest/lib/request/request.js:72:19)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  name: 'HttpError',
  code: 422,
  status: undefined,
  headers: 
   { 'access-control-allow-origin': '*',
     'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type',
     'cache-control': 'no-cache',
     connection: 'close',
     'content-length': '306',
     'content-security-policy': 'default-src \'none\'',
     'content-type': 'application/json; charset=utf-8',
     date: 'Thu, 15 Nov 2018 21:14:49 GMT',
     'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
     server: 'GitHub.com',
     status: '422 Unprocessable Entity',
     'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
     'x-content-type-options': 'nosniff',
     'x-frame-options': 'deny',
     'x-github-media-type': 'github.v3; format=json, github.machine-man-preview; format=json',
     'x-github-request-id': 'DA18:447A:93639E4:1128EFB5:5BEDE1C8',
     'x-ratelimit-limit': '30',
     'x-ratelimit-remaining': '24',
     'x-ratelimit-reset': '1542316508',
     'x-xss-protection': '1; mode=block' } }
{HttpError:{“message”:“验证失败”,“errors”:[{“message”:“无法搜索列出的用户和存储库,因为资源不存在或您没有查看它们的权限。”,“resource”:“Search”,“field”:“q”,“code”:“invalid”}],“documentation_url”:https://developer.github.com/v3/search/"}
在response.text.then.message(/Users/me/git/issue tracker/node_modules/@octokit/rest/lib/request/request.js:72:19)
在
在进程中。_tick回调(内部/process/next_tick.js:188:7)
名称:“HttpError”,
代码:422,
状态:未定义,
标题:
{“访问控制允许来源”:“*”,
“访问控制公开标头”:“ETag、链接、位置、重试后、X-GitHub-OTP、X-RateLimit-Limit、X-RateLimit-Leving、X-RateLimit-Reset、X-OAuth-Scopes、X-Accepted-OAuth-Scopes、X-Poll-Interval、X-GitHub-Media-Type”,
“缓存控制”:“无缓存”,
连接:“关闭”,
“内容长度”:“306”,
“内容安全策略”:“默认src”“无”,
“内容类型”:“应用程序/json;字符集=utf-8”,
日期:2018年11月15日星期四格林威治标准时间21:14:49,
“推荐人政策”:“交叉来源时的来源,交叉来源时的严格来源”,
服务器:'GitHub.com',
状态:“422不可处理实体”,
“严格的传输安全性”:“最大年龄=31536000;包括子域;预加载”,
“x-content-type-options”:“nosniff”,
“x帧选项”:“拒绝”,
“x-github-media-type”:“github.v3;format=json,github.machine-man-preview;format=json”,
'x-github-request-id':'DA17:447A:93639E1:1128EFAD:5BEDE1C8',
“x-ratelimit-limit”:“30”,
“x-税率限制-剩余”:“25”,
“x-ratelimit-reset”:“1542316508”,
“x-xss-protection”:“1;模式=块”}
{HttpError:{“消息”:“验证失败”,“错误”:[{“消息”:“无法搜索列出的用户和存储库,因为资源不存在或您没有查看它们的权限。”,“资源”:“搜索”,“字段”:“q”,“代码”:“无效”}],“文档\ url”:https://developer.github.com/v3/search/"}
在response.text.then.message(/Users/me/git/issue tracker/node_modules/@octokit/rest/lib/request/request.js:72:19)
在
在进程中。_tick回调(内部/process/next_tick.js:188:7)
名称:“HttpError”,
代码:422,
状态:未定义,
标题:
{“访问控制允许来源”:“*”,
“访问控制公开标头”:“ETag、链接、位置、重试后、X-GitHub-OTP、X-RateLimit-Limit、X-RateLimit-Leving、X-RateLimit-Reset、X-OAuth-Scopes、X-Accepted-OAuth-Scopes、X-Poll-Interval、X-GitHub-Media-Type”,
“缓存控制”:“无缓存”,
连接:“关闭”,
“内容长度”:“306”,
“内容安全策略”:“默认src”“无”,
“内容类型”:“应用程序/json;字符集=utf-8”,
日期:2018年11月15日星期四格林威治标准时间21:14:49,
“推荐人政策”:“交叉来源时的来源,交叉来源时的严格来源”,
服务器:'GitHub.com',
状态:“422不可处理实体”,
“严格的传输安全性”:“最大年龄=31536000;包括子域;预加载”,
“x-content-type-options”:“nosniff”,
“x帧选项”:“拒绝”,
“x-github-media-type”:“github.v3;format=json,github.machine-man-preview;format=json”,
“x-github-request-id”:“DA18:447A:93639E4:1128EFB5:5BEDE1C8”,
“x-ratelimit-limit”:“30”,
“x-税率限制-剩余”:“24”,
“x-ratelimit-reset”:“1542316508”,
“x-xss-protection”:“1;模式=块”}

这个问题让我有点困惑。

这里的问题是我传递的一个参数中的一个键有一个输入错误