通过主邮箱获取github用户名 [英] Get github username through primary email

查看:66
本文介绍了通过主邮箱获取github用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PyGithub 库邀请新成员加入组织.我面临的问题是下一个:在这种情况下,当我只知道用户的主要电子邮件时,我如何检索他的用户名以进行相应的邀请?我知道可以通过 UI 进行,但是无法通过 API 找到相应的调用.请帮忙!

I'm using the PyGithub library to invite new member to the organization. The issue I faced is the next: In the scenario, when I know only users primary email, how can I retrieve his username to proceed invite accordingly? I know it is possible through UI, but can't find the corresponding call through API. Please, assist!

推荐答案

PyGithub API

参考search_users.

search_users(query, sort=NotSet, order=NotSet, **qualifiers)

  • 查询 – 字符串
  • sort – 字符串(‘followers’、‘repositories’、‘joined’)
  • order – 字符串(‘asc’、‘desc’)
  • qualifiers – 关键字 dict 查询限定符

例如,

g = github.Github("USERNAME", "PASSWORD")
users = g.search_users("franky in:email")
for user in users:
    print(user.login)  # print the selected users' username.

GitHub API

根据 GitHub API 搜索用户,您可以使用关键字 in 指定仅通过公共电子邮件进行搜索.

GitHub API

According to GitHub API Search users, you can specify only searching by public email using keyword in.

例如,

https://api.github.com/search/users?q=franky+in:email

然后,您只会收到电子邮件中带有坦率"字样的用户.

Then, you'll only get users with "franky" in there emails.

这篇关于通过主邮箱获取github用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆