public void CheckAuth(string url) { if (_gotToken) { return; } if (url.Contains("?code=")) { var uri = new Uri(url); var queryParams = GetParams(uri.Query); if (queryParams.TryGetValue("code", out var code)) { Hide(); Close(); string token = OAuth2Helper.requestToken(GitHubApiInfo.client_id, GitHubApiInfo.client_secret, code); if (token == null) { return; } _gotToken = true; GitHubLoginInfo.OAuthToken = token; MessageBox.Show(Owner, "Successfully retrieved OAuth token.", "GitHub Authorization"); } } }
public void checkAuth(string url) { if (gotToken) { return; } if (url.Contains("?code=")) { Uri uri = new Uri(url); string code = HttpUtility.ParseQueryString(uri.Query).Get("code"); if (!code.IsNullOrEmpty()) { this.Hide(); this.Close(); string token = OAuth2Helper.requestToken(GithubAPIInfo.client_id, GithubAPIInfo.client_secret, code); if (token == null) { return; } gotToken = true; GithubLoginInfo.OAuthToken = token; MessageBox.Show(this.Owner as IWin32Window, "Successfully retrieved OAuth token.", "Github Authorization"); } } }
public void checkAuth(string url) { if (gotToken) { return; } if (url.Contains("?code=")) { Uri uri = new Uri(url); var queryParams = GetParams(uri.Query); if (queryParams.TryGetValue("code", out var code)) { this.Hide(); this.Close(); string token = OAuth2Helper.requestToken(GithubAPIInfo.client_id, GithubAPIInfo.client_secret, code); if (token == null) { return; } gotToken = true; GithubLoginInfo.OAuthToken = token; MessageBox.Show(this.Owner as IWin32Window, "Successfully retrieved OAuth token.", "Github Authorization"); } } }
public void checkAuth(string url) { if (gotToken) { return; } if (url.Contains("?code=")) { string[] splits = url.Split(new string[] { "?code=" }, StringSplitOptions.RemoveEmptyEntries); if (splits.Length == 2) { this.Hide(); this.Close(); string code = splits[1]; string token = OAuth2Helper.requestToken(GithubAPIInfo.client_id, GithubAPIInfo.client_secret, code); if (token == null) { return; } gotToken = true; GithubLoginInfo.OAuthToken = token; MessageBox.Show(this.Owner as IWin32Window, "Successfully retrieved OAuth token.", "Github Authorization"); } } }