使用 Azure Active Directory B2C 设置通过 GitHub 帐户注册与登录Set up sign-up and sign-in with a GitHub account using Azure Active Directory B2C

备注

此功能目前以公共预览版提供。This feature is in public preview.

创建 GitHub OAuth 应用程序Create a GitHub OAuth application

要将 GitHub 帐户用作 Azure Active Directory B2C (Azure AD B2C) 中的标识提供者,需要在表示它的租户中创建一个应用程序。To use a GitHub account as an identity provider in Azure Active Directory B2C (Azure AD B2C), you need to create an application in your tenant that represents it. 如果还没有 GitHub 帐户,可以在 https://www.github.com/ 注册。If you don't already have a GitHub account, you can sign up at https://www.github.com/.

  1. 使用 GitHub 凭据登录 GitHub 开发人员网站。Sign in to the GitHub Developer website with your GitHub credentials.
  2. 选择 “OAuth 应用”,然后选择 “新建 OAuth 应用”。Select OAuth Apps and then select New OAuth App.
  3. 输入应用程序名称主页 URLEnter an Application name and your Homepage URL.
  4. 在“授权回调 URL” 中输入 https://your-tenant-name.b2clogin.cn/your-tenant-name.partner.onmschina.cn/oauth2/authrespEnter https://your-tenant-name.b2clogin.cn/your-tenant-name.partner.onmschina.cn/oauth2/authresp in Authorization callback URL. your-tenant-name 替换为 Azure AD B2C 租户的名称。Replace your-tenant-name with the name of your Azure AD B2C tenant. 输入租户名称时,全部使用小写字母,即使租户是使用大写字母在 Azure AD B2C 中定义的,也是如此。Use all lowercase letters when entering your tenant name even if the tenant is defined with uppercase letters in Azure AD B2C.
  5. 单击“注册应用程序”。 Click Register application.
  6. 复制“客户端 ID” 和“客户端密钥” 的值。Copy the values of Client ID and Client Secret. 将标识提供者添加到租户时需要这两个值。You need both to add the identity provider to your tenant.

将 GitHub 帐户配置为标识提供者Configure a GitHub account as an identity provider

  1. 以 Azure AD B2C 租户的全局管理员身份登录 Azure 门户Sign in to the Azure portal as the global administrator of your Azure AD B2C tenant.
  2. 请确保使用包含 Azure AD B2C 租户的目录,方法是选择顶部菜单中的“目录 + 订阅”筛选器,然后选择包含租户的目录 。Make sure you're using the directory that contains your Azure AD B2C tenant by selecting the Directory + subscription filter in the top menu and choosing the directory that contains your tenant.
  3. 选择 Azure 门户左上角的“所有服务” ,搜索并选择 Azure AD B2CChoose All services in the top-left corner of the Azure portal, search for and select Azure AD B2C.
  4. 选择“标识提供者” ,然后选择“GitHub (预览)” 。Select Identity providers, then select GitHub (Preview).
  5. 输入“名称” 。Enter a Name. 例如,GitHub 。For example, GitHub.
  6. 对于客户端 ID,输入你之前创建的 GitHub 应用程序的客户端 ID。For the Client ID, enter the Client ID of the GitHub application that you created earlier.
  7. 对于客户端密码,输入你记录的客户端密码。For the Client secret, enter the Client Secret that you recorded.
  8. 选择“保存” 。Select Save.