Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我使用的SDK,为啥会提示我说“请求签名验证失败,请检查您的签名计算是否正确。” #290

Open
MondayR opened this issue Jan 3, 2024 · 3 comments

Comments

@MondayR
Copy link

MondayR commented Jan 3, 2024

代码是这样的
`
Credential cred = new Credential
{
SecretId = Environment.GetEnvironmentVariable("SecretId"),
SecretKey = Environment.GetEnvironmentVariable("SecretKey")
};

var cpf = new ClientProfile();

var client = new HunyuanClient(cred, "ap-chengdu");
var req = new ChatStdRequest
{
    Messages = new[]
    {
                new Message
                {
                    Role = "user",
                    Content = args[0],
                }
            }
};
try
{
    var resp = await client.ChatStd(req);

    Console.WriteLine(resp);

    foreach (var ec in resp)
    {
        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine($"------->  {ec}");
    }
}
catch (Exception ex) {
    Console.WriteLine($"----->  发生了未预期的错误!{ex.Message}");
}`

获得的结果是“-----> 发生了未预期的错误!请求签名验证失败,请检查您的签名计算是否正确。”

@needou
Copy link

needou commented Mar 5, 2024

同样问题

@zqfan
Copy link
Member

zqfan commented Mar 11, 2024

代码是这样的 ` Credential cred = new Credential { SecretId = Environment.GetEnvironmentVariable("SecretId"), SecretKey = Environment.GetEnvironmentVariable("SecretKey") };

var cpf = new ClientProfile();

var client = new HunyuanClient(cred, "ap-chengdu");
var req = new ChatStdRequest
{
    Messages = new[]
    {
                new Message
                {
                    Role = "user",
                    Content = args[0],
                }
            }
};
try
{
    var resp = await client.ChatStd(req);

    Console.WriteLine(resp);

    foreach (var ec in resp)
    {
        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine($"------->  {ec}");
    }
}
catch (Exception ex) {
    Console.WriteLine($"----->  发生了未预期的错误!{ex.Message}");
}`

获得的结果是“-----> 发生了未预期的错误!请求签名验证失败,请检查您的签名计算是否正确。”

SecretId = Environment.GetEnvironmentVariable("SecretId"), 这里需要在环境变量中先有这个Key,如果只是本地测试,你可以直接在这个位置填写密钥信息,正式环境最好是从配置文件或者环境变量中读取

@ihoeysun
Copy link

问题解决了吗?怎么解决的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants