diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/TokenModel.cs b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/TokenModel.cs new file mode 100644 index 000000000..331581805 --- /dev/null +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/TokenModel.cs @@ -0,0 +1,15 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.StackSdks.Auth.Contracts.Model; + +public class TokenModel +{ + public string AccessToken { get; set; } + + public string IdentityToken { get; set; } + + public string RefreshToken { get; set; } + + public int ExpiresIn { get; set; } +} diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs index 567d6861f..8506de7fd 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs @@ -71,7 +71,7 @@ public interface IUserService Task LoginByPhoneNumberAsync(LoginByPhoneNumberModel login); - Task LoginByPhoneNumberFromSsoAsync(string address, LoginByPhoneNumberFromSso login); + Task LoginByPhoneNumberFromSsoAsync(string address, LoginByPhoneNumberFromSso login); Task RemoveUserRolesAsync(RemoveUserRolesModel user); diff --git a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs index 225179081..c97700e62 100644 --- a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs +++ b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs @@ -221,7 +221,7 @@ public async Task UpdatePhoneNumberAsync(UpdateUserPhoneNumberModel user) return await _caller.PostAsync(requestUri, login); } - public async Task LoginByPhoneNumberFromSsoAsync(string address, LoginByPhoneNumberFromSso login) + public async Task LoginByPhoneNumberFromSsoAsync(string address, LoginByPhoneNumberFromSso login) { using var client = new HttpClient(); var disco = await client.GetDiscoveryDocumentAsync(address); @@ -242,7 +242,13 @@ public async Task LoginByPhoneNumberFromSsoAsync(string address, LoginBy if (tokenResponse.IsError) throw new UserFriendlyException(tokenResponse.Error); - return tokenResponse.AccessToken; + return new TokenModel + { + AccessToken = tokenResponse.AccessToken, + IdentityToken = tokenResponse.IdentityToken, + RefreshToken = tokenResponse.RefreshToken, + ExpiresIn = tokenResponse.ExpiresIn, + }; } public async Task RemoveUserRolesAsync(RemoveUserRolesModel user)