Tutorial Native Authentication Ios Macos Sign In User After Sign Up
In brief
The tutorial explaining automatic user sign-in after sign-up in iOS/macOS apps using native authentication was deleted.
What Entra admins need to know
Teams supporting these apps lose this tutorial as a reference for implementing automatic sign-in after registration.
This editorial summary was generated by AI from the documentation changes. Verify important details in the full Microsoft Learn article.
Documentation change
The comparison below shows only the changed extract. Use the full-page view for complete context.
deleted file mode 100644
title: Sign in user automatically after sign-up in iOS/macOS app
description: Learn how to automatically sign-in a user after sign-up in an iOS/macOS app by using native authentication.
manager: pmwongera
ms.service: identity-platform
ms.subservice: external
ms.topic: tutorial
ms.date: 09/02/2024
ms.custom:
#Customer intent: As a dev, devops, I want to learn how to automatically sign-in a user after sign-up in an iOS/macOS app by using native authentication.
Tutorial: Sign in user automatically after sign-up in an iOS/macOS app
[!INCLUDE applies-to-external-only]
This tutorial demonstrates how to sign in user automatically after sign-up in an iOS/macOS app by using native authentication.
In this tutorial, you:
[!div class="checklist"]
Sign in after sign-up.Handle errors.
Prerequisites
If you’re on iOS, follow the steps in Sign in users in sample iOS (Swift) mobile app by using native authentication. If you’re using macOS, follow the steps in Sign in users in sample macOS (Swift) app by using native authentication. These articles show you how to run sample apps that you configure using your tenant settings.Tutorial: Add sign-up in an iOS/macOS app using native authentication. The steps in this tutorial should work whether you sign up with email and password or email one-time passcode.
Sign in after sign-up
The Sign in after sign up is an enhancement functionality of the sign in user flows, which has the effect of automatically signing in after successfully signing up. The SDK provides developers the ability to sign in a user after signing up, without having to supply the username, or to verify the email address through a one-time passcode.
To sign in a user after successful sign-up use the signIn(delegate) method from the new state SignInAfterSignUpState returned in the onSignUpCompleted(newState):
extension ViewController: SignUpVerifyCodeDelegate {
func onSignUpVerifyCodeError(error: MSAL.VerifyCodeError, newState: MSAL.SignUpCodeRequiredState?) {
resultTextView.text = "Error verifying code: \(error.errorDescription ?? "no description")"
}
func onSignUpCompleted(newState: SignInAfterSignUpState) {
resultTextView.text = "Signed up successfully!"
let parameters = MSALNativeAuthSignInAfterSignUpParameters()
newState.signIn(parameters: parameters, delegate: self)
}
}
The signIn(parameters:delegate) accepts a MSALNativeAuthSignInAfterSignUpParameters instance and a delegate parameter and we must implement the required methods in the SignInAfterSignUpDelegate protocol.
In the most common scenario, we receive a call to onSignInCompleted(result) indicating that the user has signed in. The result can be used to retrieve the access token.
extension ViewController: SignInAfterSignUpDelegate {
func onSignInAfterSignUpError(error: SignInAfterSignUpError) {
resultTextView.text = "Error signing in after sign up"
}
func onSignInCompleted(result: MSAL.MSALNativeAuthUserAccountResult) {
// User successfully signed in
let parameters = MSALNativeAuthGetAccessTokenParameters()
result.getAccessToken(parameters: parameters, delegate: self)
}
}
The getAccessToken(parameters:delegate) accepts a MSALNativeAuthGetAccessTokenParameters instance and a delegate parameter and we must implement the required methods in the CredentialsDelegate protocol.
In the most common scenario, we receive a call to onAccessTokenRetrieveCompleted(result) indicating that the user obtained an access token.
extension ViewController: CredentialsDelegate {
func onAccessTokenRetrieveError(error: MSAL.RetrieveAccessTokenError) {
resultTextView.text = "Error retrieving access token"
}
func onAccessTokenRetrieveCompleted(result: MSALNativeAuthTokenResult) {
resultTextView.text = "Signed in. Access Token: \(result.accessToken)"
}
}
[!INCLUDE Custom claims provider]
Next step
[!div class="nextstepaction"] Tutorial: Self-service password reset
@@ -1,94 +0,0 @@-----title: Sign in user automatically after sign-up in iOS/macOS app-description: Learn how to automatically sign-in a user after sign-up in an iOS/macOS app by using native authentication.--manager: pmwongera--ms.service: identity-platform--ms.subservice: external-ms.topic: tutorial-ms.date: 09/02/2024-ms.custom:-#Customer intent: As a dev, devops, I want to learn how to automatically sign-in a user after sign-up in an iOS/macOS app by using native authentication.------# Tutorial: Sign in user automatically after sign-up in an iOS/macOS app--[!INCLUDE [applies-to-external-only](../external-id/includes/applies-to-external-only.md)]--This tutorial demonstrates how to sign in user automatically after sign-up in an iOS/macOS app by using native authentication. --In this tutorial, you: --> [!div class="checklist"]->-> - Sign in after sign-up. -> - Handle errors. --## Prerequisites --- If you’re on iOS, follow the steps in [Sign in users in sample iOS (Swift) mobile app by using native authentication](../external-id/customers/how-to-run-native-authentication-sample-ios-app.md). If you’re using macOS, follow the steps in [Sign in users in sample macOS (Swift) app by using native authentication](../external-id/customers/how-to-run-native-authentication-sample-macos-app.md). These articles show you how to run sample apps that you configure using your tenant settings.-- [Tutorial: Add sign-up in an iOS/macOS app using native authentication](tutorial-native-authentication-ios-macos-sign-up.md). The steps in this tutorial should work whether you sign up with email and password or email one-time passcode.--## Sign in after sign-up --The `Sign in after sign up` is an enhancement functionality of the sign in user flows, which has the effect of automatically signing in after successfully signing up. The SDK provides developers the ability to sign in a user after signing up, without having to supply the username, or to verify the email address through a one-time passcode. --To sign in a user after successful sign-up use the `signIn(delegate)` method from the new state `SignInAfterSignUpState` returned in the `onSignUpCompleted(newState)`: --```swift-extension ViewController: SignUpVerifyCodeDelegate {- func onSignUpVerifyCodeError(error: MSAL.VerifyCodeError, newState: MSAL.SignUpCodeRequiredState?) {- resultTextView.text = "Error verifying code: \(error.errorDescription ?? "no description")"- }-- func onSignUpCompleted(newState: SignInAfterSignUpState) {- resultTextView.text = "Signed up successfully!"- let parameters = MSALNativeAuthSignInAfterSignUpParameters()- newState.signIn(parameters: parameters, delegate: self)- }-}-```--The `signIn(parameters:delegate)` accepts a `MSALNativeAuthSignInAfterSignUpParameters` instance and a delegate parameter and we must implement the required methods in the `SignInAfterSignUpDelegate` protocol. --In the most common scenario, we receive a call to `onSignInCompleted(result)` indicating that the user has signed in. The result can be used to retrieve the `access token`.--```swift-extension ViewController: SignInAfterSignUpDelegate {- func onSignInAfterSignUpError(error: SignInAfterSignUpError) {- resultTextView.text = "Error signing in after sign up"- }-- func onSignInCompleted(result: MSAL.MSALNativeAuthUserAccountResult) {- // User successfully signed in- let parameters = MSALNativeAuthGetAccessTokenParameters()- result.getAccessToken(parameters: parameters, delegate: self)- }-}-```--The `getAccessToken(parameters:delegate)` accepts a `MSALNativeAuthGetAccessTokenParameters` instance and a delegate parameter and we must implement the required methods in the `CredentialsDelegate` protocol.--In the most common scenario, we receive a call to `onAccessTokenRetrieveCompleted(result)` indicating that the user obtained an `access token`.--```swift-extension ViewController: CredentialsDelegate {- func onAccessTokenRetrieveError(error: MSAL.RetrieveAccessTokenError) {- resultTextView.text = "Error retrieving access token"- }-- func onAccessTokenRetrieveCompleted(result: MSALNativeAuthTokenResult) {- resultTextView.text = "Signed in. Access Token: \(result.accessToken)"- }-}--```--[!INCLUDE [Custom claims provider](../external-id/customers/includes/native-auth/support-custom-claims-provider.md)]--## Next step --> [!div class="nextstepaction"]-> [Tutorial: Self-service password reset](tutorial-native-authentication-ios-macos-self-service-password-reset.md) 