通过主要电子邮件获取github用户名 [英] Get github username through primary email

查看:727
本文介绍了通过主要电子邮件获取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)

  • 查询–字符串
  • 排序-字符串(关注者",存储库",已加入")
  • order –字符串("asc","desc")
  • 限定词–关键字dict查询限定词
  • query – string
  • sort – string (‘followers’, ‘repositories’, ‘joined’)
  • order – string (‘asc’, ‘desc’)
  • qualifiers – keyword dict query qualifiers

例如

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:电子邮件

然后,您只会在其中收到带有坦率"字样的用户.

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

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

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