Test: Integrated google auth
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
<AssemblyName>Hutopy.Infrastructure</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using Google.Apis.Services;
|
||||
using Google.Apis.Oauth2.v2;
|
||||
using Google.Apis.Oauth2.v2.Data;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
|
||||
namespace Hutopy.Infrastructure.Services;
|
||||
|
||||
public class GoogleService : IGoogleService
|
||||
{
|
||||
public async Task<Userinfo?> GetUserInfoAsync(string accessToken)
|
||||
{
|
||||
var user = GoogleCredential.FromAccessToken(accessToken);
|
||||
|
||||
var service = new Oauth2Service(
|
||||
new BaseClientService.Initializer
|
||||
{
|
||||
HttpClientInitializer = user,
|
||||
ApplicationName = "Hutopy"
|
||||
});
|
||||
|
||||
return await service.Userinfo.Get().ExecuteAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user