建立註冊和登入使用者流程
練習:建立註冊和登入使用者流程
使用者流程定義客戶遵循的一系列註冊步驟,以及他們可以使用的登入方法 (例如電子郵件和密碼、一次性密碼,或 Google 或 Facebook 社交帳戶)。 您也可以在註冊期間從一系列內建使用者屬性中進行選取,或新增您自己的自訂屬性,向客戶收集資訊。 如果您有多個應用程式想要提供給客戶,可以建立多個使用者流程。
若要建立註冊和登入使用者流程,請登入至 Microsoft Entra 系統管理中心,然後瀏覽至 [身分識別]>[外部身分識別]。
從功能表中選取 [使用者流程]。 然後,選取 [新增使用者流程]。
在 [建立] 頁面上,輸入使用者流程的 [名稱] (例如:"SignUpSignIn")。 然後,在 [識別提供者] 下,選取 [電子郵件帳戶] 核取方塊,然後選取其中一個選項。 如果您設定了其他識別提供者,則可以選取它們。
在 [使用者屬性] 底下,選擇您在註冊期間要向使用者收集的屬性。 選取 [顯示更多] 以從完整屬性清單中選擇,包括職稱、顯示名稱和郵遞區號等。 然後,選取 [建立] 以建立使用者流程。
從清單中選取您建立的使用者流程。
以下步驟為存取您應用程式的使用者啟動註冊和登入體驗 (使用者流程)。 在左側功能表的 [使用] 底下,選取 [應用程式]。
選取 [新增應用程式]
從清單中選取應用程式。 或者,使用搜尋方塊來尋找應用程式,然後加以選取。 選擇選取。
應用程式現在已連結至使用者流程。 選取 [執行使用者流程] 以預覽體驗。
在右側開啟的 [執行使用者流程] 窗格中,確定已選取正確的 [應用程式] 和 [回覆 URL]。 然後,選取 [執行使用者流程]。
做得好! 您已成功建立使用者流程並連結應用程式!
1.建立使用者流程
若要建立使用者流程,您需要建立要求本文中指定類型的驗證事件流程物件。
POST https://graph.microsoft.com/beta/identity/authenticationEventsFlows
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#identity/authenticationEventsFlows/$entity",
"@odata.type": "#microsoft.graph.externalUsersSelfServiceSignUpEventsFlow",
"displayName": "Default sign-up and sign-in",
"description": "Woodgrove default sign-up and sign-in flow",
"priority": 500,
"conditions": {
"applications": {
"includeAllApplications": false
}
},
"onInteractiveAuthFlowStart": {
"@odata.type": "#microsoft.graph.onInteractiveAuthFlowStartExternalUsersSelfServiceSignUp",
"isSignUpAllowed": true
},
"onAuthenticationMethodLoadStart": {
"@odata.type": "#microsoft.graph.onAuthenticationMethodLoadStartExternalUsersSelfServiceSignUp",
"identityProviders": [
{
"@odata.type": "#microsoft.graph.builtInIdentityProvider",
"id": "EmailPassword-OAUTH"
}
]
},
"onAttributeCollection": {
"@odata.type": "#microsoft.graph.onAttributeCollectionExternalUsersSelfServiceSignUp",
"accessPackages": [],
"attributeCollectionPage": {
"customStringsFileId": null,
"views": [
{
"title": null,
"description": null,
"inputs": [
{
"attribute": "email",
"label": "Email Address",
"inputType": "text",
"defaultValue": null,
"hidden": true,
"editable": false,
"writeToDirectory": true,
"required": true,
"validationRegEx": "^[a-zA-Z0-9.!#$%&’'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$",
"options": []
},
{
"attribute": "displayName",
"label": "Display Name",
"inputType": "text",
"defaultValue": null,
"hidden": false,
"editable": true,
"writeToDirectory": true,
"required": true,
"validationRegEx": "^.*",
"options": []
},
{
"attribute": "country",
"label": "Country/Region",
"inputType": "radioSingleSelect",
"defaultValue": null,
"hidden": false,
"editable": true,
"writeToDirectory": true,
"required": false,
"validationRegEx": "^.*",
"options": [
{
"label": "Australia",
"value": "au"
},
{
"label": "Spain",
"value": "es"
},
{
"label": "United States",
"value": "us"
}
]
},
{
"attribute": "city",
"label": "City",
"inputType": "text",
"defaultValue": null,
"hidden": false,
"editable": true,
"writeToDirectory": true,
"required": false,
"validationRegEx": "^.*",
"options": []
}
]
}
]
},
"attributes": [
{
"id": "email"
},
{
"id": "city"
},
{
"id": "country"
},
{
"id": "displayName"
}
]
},
"onUserCreateStart": {
"@odata.type": "#microsoft.graph.onUserCreateStartExternalUsersSelfServiceSignUp",
"userTypeToCreate": "member",
"accessPackages": []
}
}
1.1 複製使用者流程識別碼
從回應中複製使用者流程識別碼的值。例如:
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#identity/authenticationEventsFlows/$entity",
"@odata.type": "#microsoft.graph.externalUsersSelfServiceSignUpEventsFlow",
"id": "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb",
"displayName": "Default sign-up and sign-in1",
"description": "Woodgrove default sign-up and sign-in flow",
...
}
2.將您的應用程式新增至使用者流程中
若要將應用程式新增或連結至使用者流程,請使用以下 Microsoft Graph 要求。 將 {user-flow-ID} 取代為您的使用者流程識別碼. 將 {app-ID} 取代為您的應用程式識別碼。
POST https://graph.microsoft.com/beta/identity/authenticationEventsFlows/{user-flow-ID}/conditions/applications/includeApplications
{
"@odata.type": "#microsoft.graph.authenticationConditionApplication",
"appId": "{app-ID}"
}