Files

27 lines
1.0 KiB
C#
Raw Permalink Normal View History

2024-04-18 01:44:37 +02:00
using System;
using Wino.Core.Domain.Exceptions;
2025-02-16 11:54:23 +01:00
namespace Wino.Core.Domain.Models.Authorization;
public class GoogleTokenizationRequest
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
public GoogleTokenizationRequest(GoogleAuthorizationRequest authorizationRequest)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
if (authorizationRequest == null)
throw new GoogleAuthenticationException("Authorization request is empty.");
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
AuthorizationRequest = authorizationRequest;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
if (string.IsNullOrEmpty(AuthorizationRequest.AuthorizationCode))
throw new GoogleAuthenticationException("Authorization request has empty code.");
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public GoogleAuthorizationRequest AuthorizationRequest { get; set; }
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public string BuildRequest()
{
return string.Format("code={0}&redirect_uri={1}&client_id={2}&code_verifier={3}&scope=&grant_type=authorization_code",
AuthorizationRequest.AuthorizationCode, Uri.EscapeDataString(GoogleAuthorizationRequest.RedirectUri), AuthorizationRequest.ClientId, AuthorizationRequest.CodeVerifier);
2024-04-18 01:44:37 +02:00
}
}