tsibelman / aws-signer-v4-dot-net

Sign HttpRequestMessage using AWS Signature v4 using request information and credentials.
Apache License 2.0
72 stars 27 forks source link

forbidden error #41

Closed BlockchainPunks closed 10 months ago

BlockchainPunks commented 10 months ago

I get forbidden error when trying to request audio data from amazon poly: "https://polly.us-east-1.amazonaws.com/v1/speech";

// Specify the URL string apiUrl = "https://polly.us-east-1.amazonaws.com/v1/speech";

// AWS credentials string _accessKey = "myaccesskey"; string _secretKey = "mysecret"; string _region = "us-east-1"; PollyRequest pollyRequest = new PollyRequest { OutputFormat = "json", Text = "Hello, this is a sample text to be synthesized.", VoiceId = "Joanna", SpeechMarkTypes = new[] { "viseme", "word" }, LexiconNames = new string[] { }, SampleRate = "22050", TextType = "text", LanguageCode = "en-US" };

// Convert the object to JSON string _json = JsonConvert.SerializeObject(pollyRequest);

var signer = new Aws4RequestSigner.AWS4RequestSigner(_accessKey, _secretKey); var content = new StringContent(_json, Encoding.UTF8, "application/json"); var request = new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = new Uri(apiUrl), Content = content };

request = await signer.Sign(request, "Polly", _region);

var client = new HttpClient(); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode();

BlockchainPunks commented 10 months ago

it was my creds - does work