-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
186 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
MailRuCloud/MailRuCloudApi/Base/Repos/YandexDisk/YadWeb/Requests/YadAuthAskV2Request.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using System.IO; | ||
using System.Net; | ||
using System.Net.Http; | ||
using YaR.Clouds.Base.Requests; | ||
|
||
namespace YaR.Clouds.Base.Repos.YandexDisk.YadWeb.Requests | ||
{ | ||
class YadAuthAskV2Request : BaseRequestJson<YadAuthAskV2RequestResult> | ||
{ | ||
private readonly IAuth _auth; | ||
private readonly string _csrf; | ||
private readonly string _uid; | ||
|
||
public YadAuthAskV2Request(HttpCommonSettings settings, IAuth auth, string csrf, string uid) | ||
: base(settings, auth) | ||
{ | ||
_auth = auth; | ||
_csrf = csrf; | ||
_uid = uid; | ||
} | ||
|
||
protected override string RelationalUri => "/registration-validations/auth/additional_data/ask_v2"; | ||
|
||
protected override HttpWebRequest CreateRequest(string baseDomain = null) | ||
{ | ||
var request = base.CreateRequest("https://passport.yandex.ru"); | ||
request.Referer = "https://passport.yandex.ru/"; | ||
request.Headers["Sec-Fetch-Mode"] = "cors"; | ||
request.Headers["Sec-Fetch-Site"] = "same-origin"; | ||
|
||
return request; | ||
} | ||
|
||
protected override byte[] CreateHttpContent() | ||
{ | ||
var keyValues = new List<KeyValuePair<string, string>> | ||
{ | ||
new KeyValuePair<string, string>("csrf_token", _csrf), | ||
new KeyValuePair<string, string>("uid", _uid), | ||
}; | ||
FormUrlEncodedContent z = new FormUrlEncodedContent(keyValues); | ||
var d = z.ReadAsByteArrayAsync().Result; | ||
return d; | ||
} | ||
} | ||
|
||
class YadAuthAskV2RequestResult | ||
{ | ||
public bool HasError => Status == "error"; | ||
|
||
[JsonProperty("status")] | ||
public string Status { get; set; } | ||
|
||
[JsonProperty("errors")] | ||
public List<string> Errors { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.