首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >一旦返回Git安装访问令牌的代码就不再这样做了。

一旦返回Git安装访问令牌的代码就不再这样做了。
EN

Stack Overflow用户
提问于 2018-11-13 20:19:16
回答 1查看 182关注 0票数 0

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

现在,我试图再次使用它,但是当我运行它时,我会得到以下错误:

TypeError:无法读取未定义的属性“access_tokens_url”

如您所见,access_tokens_url不在响应中:

代码语言:javascript
复制
{ 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命令:

代码语言:javascript
复制
curl -i -H "Authorization: Bearer blablabla" -H "Accept: application/vnd.github.machine-man-preview+json" https://api.github.com/app/installations

也应该返回数据响应,但是使用它,我得到:

代码语言:javascript
复制
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没有安装,所以我现在已经完成了。我现在面临的问题是,当我执行我的程序时,我得到了这样的信息:

代码语言:javascript
复制
Unable to authenticate

附加信息3

我重新获得了我的PEM密钥。现在我明白了:

代码语言:javascript
复制
{ 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' } }

我对这个有点困惑。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-16 15:19:43

这里的问题是,我正在传递的一个参数中的一个键有一个错误。

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

https://stackoverflow.com/questions/53288880

复制
相关文章

相似问题

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