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

await Sign error #3

Closed snabulsa closed 5 years ago

snabulsa commented 6 years ago

Hi tsibelman,

I'm using your example code and it is giving me some errors in the "await" in: request = await signer.Sign(request, "execute-api", awsSeverLocation); var response = await client.SendAsync(request); var responseStr = await response.Content.ReadAsStringAsync();

In the 3 of them the compiler is giving me this: "The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'".

Could you please what could I be missing?

Best regards,

snabulsa

tsibelman commented 6 years ago

My class using async methods so you should use it inside other async methods, to do so you should decorate your method with async keyword and return Task or Task you can see more here for example https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/

ronenfe commented 2 years ago

If you can't make the calling method async, you can use for example:

signer.Sign(request, "execute-api", _regionName).ConfigureAwait(false).GetAwaiter().GetResult();

Readme was updated with full example.

Deadlock issue is solved on version 1.0.4