Add google authentication

This commit is contained in:
Oscar Morales
2025-07-02 22:35:57 -06:00
parent 0429704cac
commit e7a3ee2389
12 changed files with 341 additions and 87 deletions

View File

@@ -0,0 +1,37 @@
using Google.Apis.Auth.OAuth2;
using Google.Apis.Oauth2.v2;
namespace Core.Thalos.BFF.Api.Services
{
public interface IGoogleAuthHelper
{
string[] GetScopes();
string ScopeToString();
ClientSecrets GetClientSecrets();
}
public class GoogleAuthHelperService(IConfiguration config) : IGoogleAuthHelper
{
public ClientSecrets GetClientSecrets()
{
string clientId = config["Authentication:Google:ClientId"]!;
string clientSecret = config["Authentication:Google:ClientSecret"]!;
return new() { ClientId = clientId, ClientSecret = clientSecret };
}
public string[] GetScopes()
{
var scopes = new[]
{
Oauth2Service.Scope.Openid,
Oauth2Service.Scope.UserinfoEmail,
Oauth2Service.Scope.UserinfoProfile
};
return scopes;
}
public string ScopeToString() => string.Join(", ", GetScopes());
}
}