简体   繁体   English

使用api在github中生成个人访问令牌

[英]Generate personal access token in github using api

有什么方法可以通过我的用户名和密码登录到我的 github 帐户并使用 api 生成个人访问令牌?

I found the solution.我找到了解决方案。 With reference to GitHub documentation https://developer.github.com/v3/guides/getting-started/#authentication I got it passed and able to make a python script that can serve my purpose.参考 GitHub 文档https://developer.github.com/v3/guides/getting-started/#authentication我通过了它并能够制作一个可以满足我的目的的 python 脚本。

Here is what should work (Postman example):这是应该起作用的(邮递员示例):

POST https://mycloud.example.com/api/v3/authorizations
{
  "note" : "example-1",
  "scopes" : [
    "repo"
  ]
}

per this blog post , they've deprecated the OAuth Authorizations API , that support generating personal access tokens.根据这篇博文,他们弃用了支持生成个人访问令牌的OAuth 授权 API

so now, you'll have to generate it using the web settings page.所以现在,您必须使用网络设置页面生成它。

Calls to OAuth Authorizations API调用 OAuth 授权 API

If you're making OAuth Authorization API calls to manage your OAuth app's authorizations or to create personal access or OAuth tokens like:如果您要进行 OAuth 授权 API 调用来管理您的 OAuth 应用程序的授权或创建个人访问或 OAuth 令牌,例如:

curl -u my_username:my_password -X POST "https://api.github.com/authorizations" -d '{"scopes":["public_repo"], "note":"my token", "client_id":"my_client_id", "client_secret":"my_client_secret"}'

Then you must switch to the web application flow to generate access tokens.然后您必须切换到 Web 应用程序流以生成访问令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM