-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changes: 1. fixed login issue caused by bilibili oauth rule change 2. bumped ui framework to 2.1.1 3. emojis pics will be cached to reduce network usage now
- Loading branch information
1 parent
d6de9b3
commit 944933f
Showing
8 changed files
with
140 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
using Org.BouncyCastle.Crypto.Parameters; | ||
using Org.BouncyCastle.Security; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
@@ -52,46 +54,27 @@ public static async Task LoginFromAccessKey(string accesskey) | |
await Account.FreshStatusAsync(); | ||
if (Account.AccessKey != "") await FreshSSO(); | ||
} | ||
public static async Task LoginV3(string username, string password, string captcha = "") | ||
public static async Task Login(string username, string password) | ||
{ | ||
string url = "https://passport.bilibili.com/api/v3/oauth2/login"; | ||
string data = $"appkey={Common.AppKey}&build={Common.Build}&mobi_app=android&password={Uri.EscapeDataString(await EncryptPassword(password))}&platform=android&ts={Common.TimeSpan}&username={Uri.EscapeDataString(username)}"; | ||
if (data != "") | ||
{ | ||
data += "&captcha=" + captcha; | ||
} | ||
var pwd = Uri.EscapeDataString(await EncryptPassword(password)); | ||
|
||
string data = $"username={Uri.EscapeDataString(username)}&password={pwd}&gee_type=10&appkey={Common.AppKey}&mobi_app=android&platform=android&ts={Common.TimeSpan}"; | ||
data += "&sign=" + Common.GetSign(data); | ||
using (HttpClient hc = new HttpClient()) | ||
{ | ||
hc.DefaultRequestHeaders.Referrer = new Uri("https://www.bilibili.com"); | ||
var response = await hc.PostAsync(url, new StringContent(data, Encoding.UTF8, "application/x-www-form-urlencoded")); | ||
hc.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 BiliDroid/5.44.2 ([email protected])"); | ||
hc.DefaultRequestHeaders.Add("referer", "https://www.bilibili.com/"); | ||
var response = await hc.PostAsync(url, new StringContent(data,Encoding.UTF8, "application/x-www-form-urlencoded")); | ||
|
||
var result = await response.Content.ReadAsStringAsync(); | ||
var model = JsonConvert.DeserializeObject<AuthModelV3>(result); | ||
Account.AccessKey = model.data.token_info.access_token; | ||
Account.AuthResultCode = model.code; | ||
await FreshSSO(); | ||
} | ||
} | ||
public static async Task LoginV2(string username, string password, string captcha = "") | ||
{ | ||
string url = "https://passport.bilibili.com/api/oauth2/login"; | ||
string data = $"appkey={Common.AppKey}&build={Common.Build}&mobi_app=android&password={Uri.EscapeDataString(await EncryptPassword(password))}&platform=android&ts={Common.TimeSpan}&username={Uri.EscapeDataString(username)}"; | ||
if (data != "") | ||
{ | ||
data += "&captcha=" + captcha; | ||
} | ||
data += "&sign=" + Common.GetSign(data); | ||
using (HttpClient hc = new HttpClient()) | ||
{ | ||
hc.DefaultRequestHeaders.Referrer = new Uri("https://www.bilibili.com"); | ||
var response = await hc.PostAsync(url, new StringContent(data, Encoding.UTF8, "application/x-www-form-urlencoded")); | ||
var result = await response.Content.ReadAsStringAsync(); | ||
var model = JsonConvert.DeserializeObject<AuthModelV2>(result); | ||
Account.AccessKey = model.data.access_token; | ||
Account.AuthResultCode = model.code; | ||
await FreshSSO(); | ||
} | ||
} | ||
|
||
public static async Task FreshSSO() | ||
{ | ||
var url = $"https://api.kaaass.net/biliapi/user/sso?access_key={Account.AccessKey}"; | ||
|
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.