API V3 を使用してプライベート Gist を Github に投稿するためにかなり長い間戦った後、私はほとんどあきらめました。ほとんど。同様の問題に直面した人や、次の動作の理由を知っている人もいるかもしれません。
現在、curl コマンドは次のようになっています。
curl -H "Authorization: bearer MY_AUTHORIZATION_TOKE" -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"public":false,"files":{"test.txt":{"content":"String file contents"}}}' https://api.github.com/gists
私も試しました
curl -H "Authorization: bearer MY_AUTHORIZATION_TOKE" -X POST -d '{"public":false,"files":{"test.txt":{"content":"String file contents"}}}' https://api.github.com/gists
まったく同じデータを使用して、認証トークンなしで要旨を作成できます。
curl -X POST -d '{"public":true,"files":{"test.txt":{"content":"String file contents"}}}' https://api.github.com/gists
ただし、その場合は匿名になります
公開として投稿しても同じ結果になります
いずれにせよ、Githubが私を返します
HTTP/1.1 404 Not Found
{
"message": "Not Found"
}
curl -H "Authorization: bearer MY_AUTHORIZATION_TOKE" https://api.github.com/user
ユーザーの詳細を返すので、私は承認されていると確信しています。
適用範囲は次のとおりです。
https://github.com/login/oauth/authorize?client_id=...&scope=gist
したがって、読み取りと書き込みの両方のアクセス許可が必要です。