vknet_vk/VkNet/Infrastructure/NeedValidationHandler.cs
Инютин Максим Николаевич f6901f2aa5 #1564 Проставляет XMLDOC
2023-07-29 17:55:07 +03:00

54 lines
No EOL
1.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Threading;
using System.Threading.Tasks;
using VkNet.Abstractions.Core;
using VkNet.Model;
using VkNet.Utils;
namespace VkNet.Infrastructure;
/// <inheritdoc cref="INeedValidationHandler" />
public class NeedValidationHandler : INeedValidationHandler
{
/// <inheritdoc />
[Obsolete(ObsoleteText.Validate)]
public AuthorizationResult Validate(string validateUrl, string phoneNumber) => throw new NotImplementedException();
/// <inheritdoc />
[Obsolete(ObsoleteText.Validate)]
public AuthorizationResult Validate(string validateUrl) => ValidateAsync(validateUrl)
.ConfigureAwait(false)
.GetAwaiter()
.GetResult();
/// <inheritdoc />
public Task<AuthorizationResult> ValidateAsync(string validateUrl, CancellationToken token = default) => throw
/*if (string.IsNullOrWhiteSpace(validateUrl))
{
throw new ArgumentException("Не задан адрес валидации!");
}
if (string.IsNullOrWhiteSpace(_authParams.Phone))
{
throw new ArgumentException("Не задан номер телефона!");
}
var validateUrlResult = await _restClient.GetAsync(new Uri(validateUrl), Enumerable.Empty<KeyValuePair<string, string>>());
var codeForm = WebForm.From(validateUrlResult)
.WithField("code")
.FilledWith(_authParams.Phone.Substring(1, 8));
var codeFormPostResult = await _restClient.PostAsync(new Uri(codeForm.ActionUrl), codeForm.GetFormFields());
var result = VkAuthorization2.From(codeFormPostResult.ResponseUri.ToString());
return new AuthorizationResult
{
AccessToken = result.AccessToken,
State = result.State,
UserId = result.UserId,
ExpiresIn = result.ExpiresIn
};*/
new NotImplementedException();
}