Open Closed

Getting JWT Authentication Token In backend #1256


User avatar
0
falsharif created

ABP Framework version: v4.2.2 UI type: / Blazor DB provider: EF Core / Tiered (MVC) or Identity Server Separated (Angular): no

i am trying to create a UI inwhich when the user registers using his phone number, the backend autogenerates the password and should return a JWT token ( Same one we get when we authenticate using connect/token endpoint.

How can i authenticate and get a token in the backend programatically so ican send it as a response. ??

public virtual async Task<string> LoginOrRegister(LoginInputDto input) { await CheckSelfRegistrationAsync();

        await IdentityOptions.SetAsync();

        var user = new IdentityUser(GuidGenerator.Create(), input.PhoneNumber, input.PhoneNumber + "@dukkantek.com", CurrentTenant.Id);
        user.SetPhoneNumber(user.UserName,true);
        (await UserManager.CreateAsync(user, "#Pp" + input.PhoneNumber)).CheckErrors();
        (await UserManager.AddDefaultRolesAsync(user)).CheckErrors();

       var token = //code to login this new user and Generate token 

        return token;
    }
    

1 Answer(s)
  • User Avatar
    1
    murat.yuceer created

    https://support.abp.io/QA/Questions/1222/Call-Api-Without-Dynamic-Proxy-Client-From-Blazor-Wasm--Http-Dynamic-Proxy-Error#answer-70a9566f-d304-2aba-52a4-39fc1df27abd

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15