尝试使用curl创建Github存储库

z9smfwbn  于 2022-11-20  发布在  Git
关注(0)|答案(1)|浏览(125)

我正在遵循指南@https://developer.github.com/guides/getting-started/在www.example.com卡住https://developer.github.com/guides/getting-started/#create-a-repository
当我跑步时

curl -i -v -H "Authorization: token ##############################" -H -d @create.txt https://api.github.com/user/repos

下面是create.txt:

"{   "name":"blog",
    "auto_init":true, 
    "private":true,
    "gitignore_template":"nanoc"
      }"

这就是结果:

Trying 192.30.253.116...
* TCP_NODELAY set
* Connected to api.github.com (192.30.253.116) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: C:\Curl\ca-bundle.crt
  CApath: none
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: C=US; ST=California; L=San Francisco; O=GitHub, Inc.; CN=*.github.com
*  start date: Apr  8 00:00:00 2014 GMT
*  expire date: Apr 12 12:00:00 2017 GMT
*  subjectAltName: host "api.github.com" matched cert's "*.github.com"
*  issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 High Assurance Server CA
*  SSL certificate verify ok.
> POST /user/repos HTTP/1.1
> Host: api.github.com
> User-Agent: curl/7.51.0
> Accept: */*
> Authorization: token ###########################################
> Content-Type: application/json
> Content-Length: 100
>
* upload completely sent off: 100 out of 100 bytes
< HTTP/1.1 404 Not Found
HTTP/1.1 404 Not Found
< Server: GitHub.com
Server: GitHub.com
< Date: Mon, 05 Dec 2016 09:31:43 GMT
Date: Mon, 05 Dec 2016 09:31:43 GMT
< Content-Type: application/json; charset=utf-8
Content-Type: application/json; charset=utf-8
< Content-Length: 87
Content-Length: 87
< Status: 404 Not Found
Status: 404 Not Found
< X-RateLimit-Limit: 5000
X-RateLimit-Limit: 5000
< X-RateLimit-Remaining: 4985
X-RateLimit-Remaining: 4985
< X-RateLimit-Reset: 1480931012
X-RateLimit-Reset: 1480931012
< X-OAuth-Scopes: gist
X-OAuth-Scopes: gist
< X-Accepted-OAuth-Scopes: public_repo, repo
X-Accepted-OAuth-Scopes: public_repo, repo
< X-GitHub-Media-Type: github.v3
X-GitHub-Media-Type: github.v3
< Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
< Access-Control-Allow-Origin: *
Access-Control-Allow-Origin: *
< Content-Security-Policy: default-src 'none'
Content-Security-Policy: default-src 'none'
< Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
< X-Content-Type-Options: nosniff
X-Content-Type-Options: nosniff
< X-Frame-Options: deny
X-Frame-Options: deny
< X-XSS-Protection: 1; mode=block
X-XSS-Protection: 1; mode=block
< X-GitHub-Request-Id: 7BED4AC8:15602:174E4027:584533FE
X-GitHub-Request-Id: 7BED4AC8:15602:174E4027:584533FE

<
{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3"
}
* Curl_http_done: called premature == 0
* Connection #0 to host api.github.com left intact

我是Git和StackExchange的新手:)。
我是否错过了create.txt的窍门?
谢谢你的时间。

afdcj2ne

afdcj2ne1#

来自GitHub OAuth API文档
检查标头以查看您拥有的OAuth范围以及API操作接受的内容。

curl -H "Authorization: token OAUTH-TOKEN" https://api.github.com/users/technoweenie -I
HTTP/1.1 200 OK
X-OAuth-Scopes: repo, user
X-Accepted-OAuth-Scopes: user

X-OAuth-Scopes列出令牌已授权的作用域。X-Accepted-OAuth-Scopes列出操作检查的作用域。
您的令牌已授权使用gist

< X-OAuth-Scopes: gist
X-OAuth-Scopes: gist
< X-Accepted-OAuth-Scopes: public_repo, repo
X-Accepted-OAuth-Scopes: public_repo, repo

相关问题