- Version 1.0.2 Se introduce un reintento en la obtención de token

This commit is contained in:
2025-09-22 20:08:59 +02:00
parent 0473c38a34
commit 2b45864ba8
2 changed files with 27 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
using Google.Apis.Auth.OAuth2;
using Google.Apis.Util.Store;
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -25,7 +26,10 @@ public static class GmailTokenManager
public static async Task<string> ObtenerAccessTokenAsync(GmailConfig config)
{
var stream = new MemoryStream(config.ClientSecret);
int i = 0;
do
{
i++;
await _tokenSemaphore.WaitAsync();
try
{
@@ -39,9 +43,16 @@ public static class GmailTokenManager
return await credencial.GetAccessTokenForRequestAsync();
}
catch (Exception ex)
{
if (i > 1) throw new Exception(ex.Message,ex);
System.Threading.Thread.Sleep(5000);
}
finally
{
_tokenSemaphore.Release();
}
}
while (true);
}
}

View File

@@ -11,6 +11,7 @@
<Company>Tecnosis S.A</Company>
<Description>Envío de correos con cuentas de gmail</Description>
<PackageReleaseNotes>
- Version 1.0.2 Se introduce un reintento en la obtención de token
- Version 1.0.1 2025-09-22 Corrección rutinas asyncronas
- Version 1.0.0 2025-09-18 Primera versión
</PackageReleaseNotes>