如何找到自己的 Github UserID
在接入GitHub的时候,需要用到用户ID(也就是UserId),却发现GitHub的Setting里没有很明显的位置可以找到,然后全网去找,发现了两种方法。
方法一、通过接口API获取UserId(推荐)
接口地址:https://api.github.com/users/你的用户名
示例:https://api.github.com/users/hddavid11
提示:接口中user要带s,网上很多接口地址都没有带s,导致返回结果是notfound,坑也就在这里。
上面示例返回结果中“id”:后的数字就是你的UserId
“login”: “hddavid11”,
“id”: 462188436,
{
"login": "hddavid11",
"id": 462188436,
"node_id": "U_kgTYDIdf9A",
"avatar_url": "https://avatars.githubusercontent.com/u/462188436?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hddavid11",
"html_url": "https://github.com/hddavid11",
方法二、在Setting中寻找
登录Github账户,点头像,选 Setting,选 Email
下滑找到: Keep my email addresses private
就能看到你的数字ID 和用户名
We’ll remove your public profile email and use 462188436+hddavid11@users.noreply.github.com when performing web-based Git operations (e.g. edits and merges) and sending email on your behalf. If you want command line Git operations to use your private email you must set your email in Git.