Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature(sdk-auth): sdk auth login #316

Merged
merged 3 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public async Task<bool> UpdatePhoneNumberAsync(UpdateUserPhoneNumberModel user)
return await _caller.PostAsync<UserModel>(requestUri, login);
}

public async Task<string> LoginByPhoneNumberFromSsoAsync(string address, LoginByPhoneNumberFromSso login)
public async Task<TokenModel> LoginByPhoneNumberFromSsoAsync(string address, LoginByPhoneNumberFromSso login)
{
using var client = new HttpClient();
var disco = await client.GetDiscoveryDocumentAsync(address);
Expand All @@ -242,7 +242,13 @@ public async Task<string> 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)
Expand Down