https://developer.github.com/apps/quickstart-guides/using-the-github-api-in-your-app/
Я следую вышеприведенному руководству по настройке GitHub API на GitHub, однако я сталкиваюсь с этой проблемой.
========================================================
Я просто запускаю sudo smee --url https://smee.io/0AcqgdnAAdZA5q --path /event_handler --port 3002
в моем терминале, а затем я создаю проблему в одном из репозиториев, в которых установлено приложение, только для целей тестирования.
И затем появляется следующая ошибка, пока smee пытаетсяперенаправьте сообщение на мой компьютер Mac,
{ Error: Unauthorized
at Request.callback (/usr/local/lib/node_modules/smee-client/node_modules/superagent/lib/node/index.js:706:15)
at IncomingMessage.parser (/usr/local/lib/node_modules/smee-client/node_modules/superagent/lib/node/index.js:916:18)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
status: 401,
response:
Response {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
res:
IncomingMessage {
_readableState: [ReadableState],
readable: false,
_events: [Object],
_eventsCount: 4,
_maxListeners: undefined,
socket: [Socket],
connection: [Socket],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers: [Object],
rawHeaders: [Array],
trailers: {},
rawTrailers: [],
aborted: false,
upgrade: false,
url: '',
method: null,
statusCode: 401,
statusMessage: 'Unauthorized ',
client: [Socket],
_consuming: false,
_dumped: false,
req: [ClientRequest],
text: '' },
request:
Request {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
_agent: false,
_formData: null,
method: 'POST',
url: 'http://127.0.0.1:3002/event_handler',
_header: [Object],
header: [Object],
writable: true,
_redirects: 0,
_maxRedirects: 5,
cookies: '',
qs: {},
_query: [],
qsRaw: [],
_redirectList: [],
_streamRequest: false,
_data: [Object],
req: [ClientRequest],
protocol: 'http:',
host: '127.0.0.1:3002',
_endCalled: true,
_callback: [Function],
res: [IncomingMessage],
response: [Circular],
called: true },
req:
ClientRequest {
_events: [Object],
_eventsCount: 3,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 7597,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [Socket],
connection: [Socket],
_header:
'POST /event_handler HTTP/1.1\r\nhost: smee.io\r\nAccept-Encoding: gzip, deflate\r\nuser-agent: GitHub-Hookshot/b4238f9\r\ncontent-type: application/json\r\nconnection: close\r\naccept: */*\r\nx-github-event: issues\r\nx-github-delivery: 2ffd9d80-fba0-11e9-8f34-9987220100a1\r\nx-hub-signature: sha1=9b59ee3122af7a623934083d8d5432f32a7d42d6\r\nx-request-id: f422646b-fb28-4904-9b88-7294c9a01fbe\r\nx-forwarded-for: 140.82.115.249\r\nx-forwarded-proto: https\r\nx-forwarded-port: 443\r\nvia: 1.1 vegur\r\nconnect-time: 0\r\nx-request-start: 1572500103861\r\ntotal-route-time: 0\r\ncontent-length: 7597\r\ntimestamp: 1572500103863\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: [Agent],
socketPath: undefined,
timeout: undefined,
method: 'POST',
path: '/event_handler',
_ended: true,
res: [IncomingMessage],
aborted: undefined,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
[Symbol(isCorked)]: false,
[Symbol(outHeadersKey)]: [Object] },
text: '',
body: {},
files: undefined,
buffered: true,
headers:
{ 'content-type': 'text/html;charset=utf-8',
'content-length': '0',
'x-xss-protection': '1; mode=block',
'x-content-type-options': 'nosniff',
'x-frame-options': 'SAMEORIGIN',
server: 'WEBrick/1.3.1 (Ruby/2.3.7/2018-03-28)',
date: 'Thu, 31 Oct 2019 05:35:04 GMT',
connection: 'close' },
header:
{ 'content-type': 'text/html;charset=utf-8',
'content-length': '0',
'x-xss-protection': '1; mode=block',
'x-content-type-options': 'nosniff',
'x-frame-options': 'SAMEORIGIN',
server: 'WEBrick/1.3.1 (Ruby/2.3.7/2018-03-28)',
date: 'Thu, 31 Oct 2019 05:35:04 GMT',
connection: 'close' },
statusCode: 401,
status: 401,
statusType: 4,
info: false,
ok: false,
redirect: false,
clientError: true,
serverError: false,
error:
{ Error: cannot POST /event_handler (401)
at Response.toError (/usr/local/lib/node_modules/smee-client/node_modules/superagent/lib/node/response.js:94:15)
at ResponseBase._setStatusProperties (/usr/local/lib/node_modules/smee-client/node_modules/superagent/lib/response-base.js:123:16)
at new Response (/usr/local/lib/node_modules/smee-client/node_modules/superagent/lib/node/response.js:41:8)
at Request._emitResponse (/usr/local/lib/node_modules/smee-client/node_modules/superagent/lib/node/index.js:752:20)
at IncomingMessage.parser (/usr/local/lib/node_modules/smee-client/node_modules/superagent/lib/node/index.js:916:38)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19) status: 401, text: '', method: 'POST', path: '/event_handler' },
created: false,
accepted: false,
noContent: false,
badRequest: false,
unauthorized: true,
notAcceptable: false,
forbidden: false,
notFound: false,
unprocessableEntity: false,
type: 'text/html',
charset: 'utf-8',
links: {},
setEncoding: [Function: bound ],
redirects: [] } }
Но я уверен, что смее успешно получает webhook от сервера GitHub, это просто что-то не так при перенаправлении перехвата на мой личныйкомпьютер mac . Доказательством является то, что я могу просмотреть сообщение с веб-сайта smee .
На моем компьютере Mac запущен скрипт, выполняющий роль локального сервера, ожидающий перенаправления с smee . Но я думаю, что это не относится к данному вопросу, поэтому я не собираюсь публиковать здесь код. Это просто простой скрипт ruby, скопированный из репозитория Github.