diff --git a/src/Snap.Hutao.Server/Snap.Hutao.Server/Controller/GithubAuthorizationController.cs b/src/Snap.Hutao.Server/Snap.Hutao.Server/Controller/GithubAuthorizationController.cs index 0f39587..fd63eb0 100644 --- a/src/Snap.Hutao.Server/Snap.Hutao.Server/Controller/GithubAuthorizationController.cs +++ b/src/Snap.Hutao.Server/Snap.Hutao.Server/Controller/GithubAuthorizationController.cs @@ -103,14 +103,9 @@ public async Task HandleAuthorizationCallbackAsync([FromQuery(Nam } GithubAccessTokenResponse? accessTokenResponse; - using (HttpRequestMessage requestMessage = new(HttpMethod.Post, "https://github.com/login/oauth/access_token")) + string accessTokenQuery = $"client_id={githubOptions.ClientId}&client_secret={githubOptions.ClientSecret}&code={code}"; + using (HttpRequestMessage requestMessage = new(HttpMethod.Post, $"https://github.com/login/oauth/access_token?{accessTokenQuery}")) { - requestMessage.Content = new FormUrlEncodedContent(new Dictionary - { - ["client_id"] = githubOptions.ClientId, - ["client_secret"] = githubOptions.ClientSecret, - ["code"] = code, - }); requestMessage.Headers.Accept.Add(new("application/json")); requestMessage.Headers.Authorization = new("token", code);