C#初心者です。 C#でLINEWORKS API 2.0でAccessToken取得をしていますが、 メソッドを呼び出そうとすると構文エラー…。 どのような形でパラメータを渡せばよいのかご教授ください。 string PrivateKeyPath = "~/private.key"; string ServerAccount = "#"; string ClientId = "#"; string ClientSecret = "#"; string[] SCOPES = { "bot", "bot.read" }; string token; FileInfo fi = new FileInfo(PrivateKeyPath); token = GetToken(fi, ServerAccount, ClientId, ClientSecret, SCOPES);←ここで構文エラー Dictionary<string, string> GetToken(FileInfo privateKey, string service_account, string client_id, string client_secret, params string[] scopes) { using (var rsa = RSA.Create()) { rsa.ImportFromPem(File.ReadAllText(privateKey.FullName)); var descriptor = new Microsoft.IdentityModel.Tokens.SecurityTokenDescriptor { Issuer = client_id, Claims = new Dictionary<string, object>() { ["sub"] = service_account }, SigningCredentials = new Microsoft.IdentityModel.Tokens.SigningCredentials(new Microsoft.IdentityModel.Tokens.RsaSecurityKey(rsa), "RS256"), IssuedAt = DateTime.UtcNow, Expires = DateTime.UtcNow.AddMinutes(60), }; var handler = new System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler(); var pv = new System.Collections.Specialized.NameValueCollection() { ["assertion"] = handler.WriteToken(handler.CreateJwtSecurityToken(descriptor)), ["grant_type"] = @"urn:ietf:params:oauth:grant-type:jwt-bearer", ["client_id"] = client_id, ["client_secret"] = client_secret, ["scope"] = string.Join(",", scopes), }; using (var wc = new System.Net.WebClient()) { var resText = Encoding.ASCII.GetString(wc.UploadValues(@"https://auth.worksmobile.com/oauth2/v2.0/token", pv)); return System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, string>>(resText); } } }
C言語関連