Fix HttpUtility reference in auth URL builder
This commit is contained in:
@@ -30,15 +30,20 @@ public class YouTubeAuthService
|
|||||||
|
|
||||||
public string GetAuthorizationUrl(string redirectUri)
|
public string GetAuthorizationUrl(string redirectUri)
|
||||||
{
|
{
|
||||||
var parameters = HttpUtility.ParseQueryString(string.Empty);
|
var query = new[]
|
||||||
parameters["client_id"] = _clientId;
|
{
|
||||||
parameters["redirect_uri"] = redirectUri;
|
("client_id", _clientId),
|
||||||
parameters["response_type"] = "code";
|
("redirect_uri", redirectUri),
|
||||||
parameters["scope"] = Scope;
|
("response_type", "code"),
|
||||||
parameters["access_type"] = "offline";
|
("scope", Scope),
|
||||||
parameters["prompt"] = "consent";
|
("access_type", "offline"),
|
||||||
|
("prompt", "consent"),
|
||||||
|
};
|
||||||
|
|
||||||
return $"{AuthorizationEndpoint}?{parameters}";
|
var encoded = string.Join("&", query.Select(kv =>
|
||||||
|
$"{Uri.EscapeDataString(kv.Item1)}={Uri.EscapeDataString(kv.Item2)}"));
|
||||||
|
|
||||||
|
return $"{AuthorizationEndpoint}?{encoded}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<YouTubeChannel?> ExchangeCodeForToken(string code, string redirectUri)
|
public async Task<YouTubeChannel?> ExchangeCodeForToken(string code, string redirectUri)
|
||||||
|
|||||||
Reference in New Issue
Block a user