Add google authentication
This commit is contained in:
		
							
								
								
									
										37
									
								
								Core.Thalos.BFF.Api/Services/IGoogleAuthHelper.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								Core.Thalos.BFF.Api/Services/IGoogleAuthHelper.cs
									
									
									
									
									
										Normal 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()); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Oscar Morales
					Oscar Morales