mirror of
https://github.com/vknet/vk.git
synced 2026-07-10 00:18:28 +00:00
54 lines
No EOL
1.7 KiB
C#
54 lines
No EOL
1.7 KiB
C#
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();
|
||
} |