Comments (13)
Tried the curl with my token, it spits out:
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest"
}
Thank you very much. I contacted support and referenced the issue.
from core.js.
Try this:
octokit
.request("GET /")
.then(console.log, console.log);
If you get a 404 error, the token is invalid. If it logs the response, look for
'x-oauth-scopes': 'gist',
in the response header. My guess is that either the token you pass in auth: token
is invalid, or it does not have the gist
scope.
from core.js.
Most likely the token does not have the βgistβ scope. Can you log the full error?
from core.js.
HttpError: Bad credentials
at /Users/mo/..../note/node_modules/@octokit/request/dist-node/index.js:66:23
at processTicksAndRejections (node:internal/process/task_queues:93:5)
at async /Users/mo/..../note/cli.js:94:5
- I only specifically allowed the "gist" scope.
from core.js.
I was not able to reproduce the problem.
const octokit = new Octokit({
auth: "MY TOKEN",
});
octokit
.request("POST /gists", {
files: {
"test.txt": {
content: "test",
},
},
})
.then(console.log, console.log);
Here is the gist it created
https://gist.github.com/gr2m/8941225b4aa0e8136b35911915beca9e
Can you please log the error and share what it logs?
await octokit.request('POST /gists', {
files: saveGist
}).catch(console.log)
from core.js.
RequestError [HttpError]: Bad credentials
at /Users/mo/..../note/node_modules/@octokit/request/dist-node/index.js:66:23
at processTicksAndRejections (node:internal/process/task_queues:93:5) {
status: 401,
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-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset',
connection: 'close',
'content-length': '80',
'content-security-policy': "default-src 'none'",
'content-type': 'application/json; charset=utf-8',
date: 'Tue, 24 Nov 2020 09:06:41 GMT',
'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
server: 'GitHub.com',
status: '401 Unauthorized',
'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
vary: 'Accept-Encoding, Accept, X-Requested-With',
'x-content-type-options': 'nosniff',
'x-frame-options': 'deny',
'x-github-media-type': 'github.v3; format=json',
'x-github-request-id': 'D0C7:9CC2:735169:904C40:5FBCCD21',
'x-ratelimit-limit': '60',
'x-ratelimit-remaining': '54',
'x-ratelimit-reset': '1606211195',
'x-ratelimit-used': '6',
'x-xss-protection': '1; mode=block'
},
request: {
method: 'POST',
url: 'https://api.github.com/gists',
headers: {
accept: 'application/vnd.github.v3+json',
'user-agent': 'octokit-core.js/3.2.1 Node.js/15.2.1 (darwin; x64)',
authorization: 'token [REDACTED]',
'content-type': 'application/json; charset=utf-8'
},
body: '{"files":{"test.txt":{"content":"test"}}}',
request: { hook: [Function: bound bound register] }
},
documentation_url: 'https://docs.github.com/rest'
}
I tried with a new token only allowed gists
, same problem.
Thanks a lot for taking a look btw.
from core.js.
Can you try to reproduce the problem using curl
?
Try
curl -XPOST -H"Authorization: token [TOKEN HERE]" https://api.github.com/gist -d ''{"files":{"test.txt":{"content":"test"}}}''
If you still see the error, I'd suggest to contact support: support.github.com/contact. You can reference this issue and share the request ID: D0C7:9CC2:735169:904C40:5FBCCD21
. They have tools to look it up and find out exactly what is happening. I'm out of ideas I'm afraid
from core.js.
curl -XPOST -H"Authorization: token [TOKEN HERE]" https://api.github.com/gist -d ''{"files":{"test.txt":{"content":"test"}}}''
That should be gists
not gist
π -- hence the "Not Found"
curl -XPOST -H"Authorization: token [TOKEN HERE]" https://api.github.com/gists -d '{"files":{"test.txt":{"content":"test"}}}'
from core.js.
oopsie, thanks Simon! Can you try that again Mohamed?
from core.js.
Awesome. The curl works. But I still don't know why using the library fails:
const octokit = new Octokit({
auth: token,
});
octokit.request('POST /gists', {
files: {
"test.txt": {
content: "test"
}
}
}).then(console.log, console.log);
from core.js.
Thanks a lot @gr2m
from core.js.
@nayebare Can you try instantiating Octokit
like this? What you're doing right not doesn't look quite right:
let octokit = new Octokit({ auth: process.env.GITHUB_TOKEN })
from core.js.
If you console.log(process.env.GITHUB_TOKEN)
, does anything show up?
from core.js.
Related Issues (20)
- [FEAT]: Escape slash in request parameters to `--` HOT 3
- [DOCS]: Error response schema HOT 3
- [BUG]: Uncaught ReferenceError: global is not defined HOT 7
- [BUG]: octokit.graphql gives increasing number of duplicate HOT 1
- [BUG]: can not intercept requests with nock HOT 2
- [BUG]: Octokit version 4.2.2 has a breaking change dependency upgrade HOT 2
- https://github.com/ietf-tools/datatracker/commit/e68b9cf60c0f6771e40ed73a4f59aa47cacbb854
- Re-enable tests in `@octokit/core` using fetch dispatchers HOT 2
- Avoid JSON.stringify hack when testing responses of fetch-mock HOT 7
- Replace `toStrictEqual` with `JSON.stringify` Response assertions with `toEqual` in `core.js` HOT 1
- [BUG]: Unexpected token '{' in Safari pre 16.3 HOT 4
- [BUG]: Rest call to delete comment returns 404 HOT 3
- [MAINT]: Replace lolex with @sinon/fake-timers HOT 2
- [BUG]: OctokitOptions declared locally but not exported HOT 7
- [QUESTION] Is there an alternative version of this project written in c#? HOT 2
- [BUG]: The type of 'data' field in OctokitResponse type is an object but type hinting show it's an array HOT 2
- [BUG]: Commit not found when it exists HOT 2
- [BUG]: `No "exports" main defined` in version 6.0.1 HOT 5
- [BUG/ASK for HELP]: Issues with `@octokit/[email protected]+` when using `ncc` to bundle code HOT 6
- [BUG]: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in HOT 24
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.js.