Opayo API - Unable to validate signature - c#

I have been trying to connect to the Opayo 'Reporting & Admin API' and use the command 'getTransactionDetail' (https://developer-eu.elavon.com/docs/opayo-reporting-api/reporting-commands/gettransactiondetail), but keep getting back error 0010, which indicates that the API Cannot validate the signature value. We have been able to login with our Vendor/Username/Password combination, validating that they are all correct.
The code we are using when sending a POST to the API is below - with certain elements blocked out for security purposes.
using System;
using System.Collections.Specialized;
using System.Security.Cryptography;
using System.Text;
using System.Net;
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string signature = "<command>getTransactionDetail</command><vendor>[Vendor]</vendor><user>[User]</user><vendortxcode>[VendorTXCode]</vendortxcode><password>[Password]</password>";
using (MD5 md5 = MD5.Create())
{
byte[] inputBytes = Encoding.Unicode.GetBytes(signature);
byte[] hashBytes = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("X2"));
}
signature = sb.ToString();
}
string xmlToPost = "<vspaccess><command>getTransactionDetail</command><vendor>[Vendor]</vendor><user>[User]</user><vendortxcode>[VendorTXCode]</vendortxcode><signature>" + signature + "</signature></vspaccess>";
using (WebClient client = new WebClient())
{
client.BaseAddress = "https://test.sagepay.com";
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
client.Encoding = Encoding.UTF8;
var content = new NameValueCollection()
{
{ "XML", xmlToPost }
};
string response = Encoding.UTF8.GetString(client.UploadValues("/access/access.htm", content));
}
}
}
Any help in resolving this issue would be appreciated!

Turns out due to the fact we were using Forms integration for our initial payment, we had to instead use the following API documentation: https://developer-eu.elavon.com/docs/opayo/spec/api-reference
More specifically this part related to repeats: https://developer-eu.elavon.com/docs/opayo/spec/api-reference#operation/createTransaction
Note the code examples on the right hand side!

In case it helps others looking for Opayo Admin and Reporting API help:
I had the same issue, so I created a NuGet package for the API-client code here: https://github.com/joeratzer/opayo-admin-and-reporting-api-client.
You can find the NuGet package here:
https://www.nuget.org/packages/Joe.Opayo.Admin.Api.Client/1.1.0
The client app allows code like this:
var client = new OpayoAdminApiClient();
var isTest = true;
var request = new OpayoApiRequest(ApiCommandType.GetTransactionDetail, "password", isTest, "user-name", "vendor-name");
var commandSpecificXml = "<vendortxcode>01Jan2010Transaction12345</vendortxcode>";
return await client.ProcessApiCommandAsync<TransactionDetail>(request, commandSpecificXml);

Related

Microsoft Linguistic Analysis API example HttpUtility does not exist

I'm trying to check Microsoft Linguistic Analysis API, basic example, so I have subscribed and addad my Key 1 in Ocp-Apim-Subscription-Key and Key 2 into the subscription key here client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");.
Then I add Newtonsoft.Json with Manage NuGet Packages into the References of Application, even it is not listed in using of particular example using Newtonsoft.Json; using bNewtonsoft.Json.Serialization; not sure, I'm new with this tool.
I'm trying to check this example Linguistics API for C# to get some natural language processing results for text analysis mainly of Verb and Noun values according to this example results So I'm not sure if I'm on the right direction with this example, or possible I've missed something to install, maybe I need some additions. I found this Analyze Method not sure how and if I have to use it for this particular goal.
But seems like something is wrong with var queryString = HttpUtility.ParseQueryString(string.Empty); and HttpUtility does not exist.
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
// Request headers
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");
var uri = "https://westus.api.cognitive.microsoft.com/linguistics/v1.0/analyze?" + queryString;
HttpResponseMessage response;
// Request body
byte[] byteData = Encoding.UTF8.GetBytes("{body}");
using (var content = new ByteArrayContent(byteData))
{
content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
response = await client.PostAsync(uri, content);
}
}
}
}
You can create a new writeable instance of HttpValueCollection by calling System.Web.HttpUtility.ParseQueryString(string.Empty), and then use it as any NameValueCollection, like this:
NameValueCollection queryString = System.Web.HttpUtility.ParseQueryString(string.Empty);
Try adding a reference to System.Web, and possibly to System.Runtime.Serialization.

NotificationHub send notification in registered tag UWP

Is there a way to send a notification with UWP app through NotificationHub? In many tutorials they send notifications with a C# console application using Microsoft.Azure.NotificationHubs Nuget package. I cannot install this package in a UWP app.
Can i specifically send a notification to a tagged device that i register with RegisterNativeAsync?
Per my experience, I think the simple way for sending notification in a UWP app is to using Notification Hub REST APIs via HttpClient, without the issues for platform compatibility.
Please refer to the document Notification Hubs REST APIs.
You can try to refer to the doc Using REST APIs from a Backend to make your UWP app as a backend to send messages. For example, Send a WNS Native Notification.
Hope it helps.
I finally found the solution. The code is like #Kyle but i had to add
request.Headers.Add("X-WNS-Type", "wns/toast");
in order to send a push notification
More details
Here's a working code that sends a notification from a UWP through an Azure Notification Hub (However, it uses GCM instead of WNS, see how to change the code in the approved answer). It obviously needs a few changes like your hub's name, see the comments in the code for more info.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using Windows.Storage.Streams;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace SendNotification
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.sendNotification();
}
string Endpoint = "";
string SasKeyName = "";
string SasKeyValue = "";
public void ConnectionStringUtility(string connectionString)
{
//Parse Connectionstring
char[] separator = { ';' };
string[] parts = connectionString.Split(separator);
for (int i = 0; i < parts.Length; i++)
{
if (parts[i].StartsWith("Endpoint"))
Endpoint = "https" + parts[i].Substring(11);
if (parts[i].StartsWith("SharedAccessKeyName"))
SasKeyName = parts[i].Substring(20);
if (parts[i].StartsWith("SharedAccessKey"))
SasKeyValue = parts[i].Substring(16);
}
}
public string getSaSToken(string uri, int minUntilExpire)
{
string targetUri = Uri.EscapeDataString(uri.ToLower()).ToLower();
// Add an expiration in seconds to it.
long expiresOnDate = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
expiresOnDate += minUntilExpire * 60 * 1000;
long expires_seconds = expiresOnDate / 1000;
String toSign = targetUri + "\n" + expires_seconds;
// Generate a HMAC-SHA256 hash or the uri and expiration using your secret key.
MacAlgorithmProvider macAlgorithmProvider = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha256);
BinaryStringEncoding encoding = BinaryStringEncoding.Utf8;
var messageBuffer = CryptographicBuffer.ConvertStringToBinary(toSign, encoding);
IBuffer keyBuffer = CryptographicBuffer.ConvertStringToBinary(SasKeyValue, encoding);
CryptographicKey hmacKey = macAlgorithmProvider.CreateKey(keyBuffer);
IBuffer signedMessage = CryptographicEngine.Sign(hmacKey, messageBuffer);
string signature = Uri.EscapeDataString(CryptographicBuffer.EncodeToBase64String(signedMessage));
return "SharedAccessSignature sr=" + targetUri + "&sig=" + signature + "&se=" + expires_seconds + "&skn=" + SasKeyName;
}
public async void sendNotification()
{
ConnectionStringUtility("YOURHubFullAccess"); //insert your HubFullAccess here (a string that can be copied from the Azure Portal by clicking Access Policies on the Settings blade for your notification hub)
//replace YOURHUBNAME with whatever you named your notification hub in azure
var uri = Endpoint + "YOURHUBNAME" + "/messages/?api-version=2015-01";
string json = "{\"data\":{\"message\":\"" + "Hello World!" + "\"}}";
//send an HTTP POST request
using (var httpClient = new HttpClient())
{
var request = new HttpRequestMessage(HttpMethod.Post, uri);
request.Content = new StringContent(json);
request.Headers.Add("Authorization", getSaSToken(uri, 1000));
request.Headers.Add("ServiceBusNotification-Format", "gcm");
var response = await httpClient.SendAsync(request);
await response.Content.ReadAsStringAsync();
}
}
}
}
Did you try WindowsAzure.Messaging.Managed? Just tried it with the W10 UWP.
https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-windows-store-dotnet-get-started/

Sending notification to Azure Notification Hub from Universal Windows Platform (UWP) app

As the title suggests, I need to send a notification FROM a UWP app (written in C#) to my Azure's hub (and from there it's sent to an Android app that I've already created). I obviously use GCM in order to send push notification to my Android app.
After countless hours of searching I have yet to find a single tutorial that would somehow be of use, since most of them use a console application in order to send the notification, not a Universal Windows Platform app.
If anyone could please help me I'd be really thankful.
You can use the Notification Hub REST APIs to push a notification from anywhere (backend or device) over vanilla HTTP/HTTPS.
There is a sample (using a Java client) here: https://msdn.microsoft.com/en-us/library/azure/dn495628.aspx
And the API reference is here: https://msdn.microsoft.com/en-us/library/azure/dn495827.aspx
I'm gonna answer my own question here since a lot of people struggled with this like me. So here's a code that sends a notification from a Universal Windows Platform (UWP) through an Azure Notification Hub, to an Android app (using GCM).
Please note that MUST slightly change the code for it to work on your own notification hub (see the comments in the code for more details)
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using Windows.Storage.Streams;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace SendNotification
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.sendNotification();
}
string Endpoint = "";
string SasKeyName = "";
string SasKeyValue = "";
public void ConnectionStringUtility(string connectionString)
{
//Parse Connectionstring
char[] separator = { ';' };
string[] parts = connectionString.Split(separator);
for (int i = 0; i < parts.Length; i++)
{
if (parts[i].StartsWith("Endpoint"))
Endpoint = "https" + parts[i].Substring(11);
if (parts[i].StartsWith("SharedAccessKeyName"))
SasKeyName = parts[i].Substring(20);
if (parts[i].StartsWith("SharedAccessKey"))
SasKeyValue = parts[i].Substring(16);
}
}
public string getSaSToken(string uri, int minUntilExpire)
{
string targetUri = Uri.EscapeDataString(uri.ToLower()).ToLower();
// Add an expiration in seconds to it.
long expiresOnDate = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
expiresOnDate += minUntilExpire * 60 * 1000;
long expires_seconds = expiresOnDate / 1000;
String toSign = targetUri + "\n" + expires_seconds;
// Generate a HMAC-SHA256 hash or the uri and expiration using your secret key.
MacAlgorithmProvider macAlgorithmProvider = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha256);
BinaryStringEncoding encoding = BinaryStringEncoding.Utf8;
var messageBuffer = CryptographicBuffer.ConvertStringToBinary(toSign, encoding);
IBuffer keyBuffer = CryptographicBuffer.ConvertStringToBinary(SasKeyValue, encoding);
CryptographicKey hmacKey = macAlgorithmProvider.CreateKey(keyBuffer);
IBuffer signedMessage = CryptographicEngine.Sign(hmacKey, messageBuffer);
string signature = Uri.EscapeDataString(CryptographicBuffer.EncodeToBase64String(signedMessage));
return "SharedAccessSignature sr=" + targetUri + "&sig=" + signature + "&se=" + expires_seconds + "&skn=" + SasKeyName;
}
public async void sendNotification()
{
//insert your HubFullAccess here (a string that can be copied from the Azure Portal by clicking Access Policies on the Settings blade for your notification hub)
ConnectionStringUtility("YOURHubFullAccess");
//replace YOURHUBNAME with whatever you named your notification hub in azure
var uri = Endpoint + "YOURHUBNAME" + "/messages/?api-version=2015-01";
string json = "{\"data\":{\"message\":\"" + "Hello World!" + "\"}}";
//send an HTTP POST request
using (var httpClient = new HttpClient())
{
var request = new HttpRequestMessage(HttpMethod.Post, uri);
request.Content = new StringContent(json);
request.Headers.Add("Authorization", getSaSToken(uri, 1000));
request.Headers.Add("ServiceBusNotification-Format", "gcm");
var response = await httpClient.SendAsync(request);
await response.Content.ReadAsStringAsync();
}
}
}
}

Calling an API asynchronously and parsing JSON

I come from an iOS (Swift) background. In one of my Swift apps, I have this class that calls an API. I'm trying to port it to C# (Windows Form application) but I'm hitting several snags. First here's the Swift code. Nothing fancy. One method does a POST request to login to the API and the other function executes a GET method to retrieve the JSON response for a user profile. Both these methods are asynchronous.
import Foundation
class API {
private let session = NSURLSession.sharedSession()
private let baseURL = "https://www.example.com/api/"
func login(userID userID: String, password: String, completion: (error: NSError?) -> ()) {
let url = NSURL(string: baseURL + "login")!
let params = ["username": userID, "password": password]
let request = NSMutableURLRequest(URL: url)
request.HTTPMethod = "POST"
request.encodeParameters(params) // encodeParameters is an extension method
session.dataTaskWithRequest(request, completionHandler: { data, response, error in
if let httpResponse = response as? NSHTTPURLResponse {
if httpResponse.statusCode != 200 {
completion(error: error)
} else {
completion(error: nil)
}
}
}).resume()
}
func fetchUser(completion: (user: User?, error: NSError?) -> ()) {
let url = NSURL(string: baseURL + "profile")!
let request = NSURLRequest(URL: url)
session.dataTaskWithRequest(request, completionHandler: { data, response, error in
if let error = error {
completion(user: nil, error: error)
} else {
// Parsing JSON
var jsonDict = [String: AnyObject]()
do {
jsonDict = try NSJSONSerialization.JSONObjectWithData(data, options: []) as! [String: AnyObject]
} catch {
print("Error occurred parsing data: \(error)")
completion(user: nil, error: error)
}
let user = User()
user.name = jsonDict["name"] as! String
user.age = jsonDict["age"] as! Int
completion(user: user, error: nil)
}
}).resume()
}
}
Here's my attempt to convert this to C#.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Http;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Xml.Linq;
using System.Xml.XPath;
namespace MyTrayApp
{
public partial class Form1 : Form
{
private string baseURL = "https://www.example.com/api/";
public Form1()
{
InitializeComponent();
}
private async void Form1_Load(object sender, EventArgs e)
{
await login("myusername", "mypassword");
await fetchUser();
}
async Task login(string userID, string password)
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(baseURL);
var parameters = new Dictionary<string, string>
{
{ "username", userID },
{ "password", password }
};
var encodedParameters = new FormUrlEncodedContent(parameters);
var response = await client.PostAsync("login", encodedParameters);
string responseString = await response.Content.ReadAsStringAsync();
//Console.WriteLine(responseString);
}
}
async Task fetchUser()
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(baseURL);
var response = await client.GetAsync("profile");
response.EnsureSuccessStatusCode();
var responseString = await response.Content.ReadAsStringAsync();
var jsonReader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(responseString.ToCharArray()), new System.Xml.XmlDictionaryReaderQuotas());
var root = XElement.Load(jsonReader);
Console.WriteLine(root.XPathSelectElement("//name").Value);
//Console.WriteLine(responseString);
}
}
}
}
These are the problems I'm having.
In my Swift methods, they have completion handlers. How can I do the same in C#?
In Swift, you get an NSData object and you can pass it to NSJSONSerialization to create a JSON object. In my current implementation, I get an XML exception at XElement.Load(jsonReader);. I'm not sure if this is the correct way to do this even. I found tons of different solutions here on SO. But some are for Metro apps, some are for web it's all too overwhelming. Also most solutions are on using third-party libraries like JSON.NET. I'm trying to achieve this without third-party libraries.
In my Swift methods, they have completion handlers. How can I do the
same in C#?
The point of wiring up a completion handler is so that you don't tie up a thread while waiting for the HTTP call to complete. The beauty of async/await is that you don't have to do this in C#. The await keyword instructs the compiler to literally rewrite the rest of the method as a callback. The current thread is freed as soon as await is encountered, preventing your UI from freezing up. You have written your async code correctly; it will behave asynchronously even though it looks synchronous.
Your second question is a bit broad, but I will make 2 suggestions:
Don't use XElement when dealing with JSON data. That part of an Microsoft's XML parsing library (one of them) and has nothing to do with JSON.
I'm not sure why achieving this without a 3rd-party library is important. I know people have their reasons, but Json.NET in particular has become so popular and ubiquitous that Microsoft itself has baked it into their ASP.NET MVC and Web API frameworks. That said, if you must avoid it, here is how you would deserialize JSON using only Microsoft libraries.

Alexa TopSites - Continuous Signature Failures - C# Implementation

I've asked this on the AWS Forums but getting plenty of views but no comments, I wonder if anyone here can shed any light on it?
Hi,
I've been trying to write a simple c# console application to call the topsites service for two days now and still get issues with the signature generation.
I've tested using a java sample in the gallery and can successfully query using my accesskeyid and secret. I've then used my C# code to prove I can generate the same signature and my code will do so, however when I then craft a request and issue it against the api every single one returns a 403 status - signaturedoesnotmatch - please can someone help me find out what the issue is? I'm tearing my hair out with this.
C# Code:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace ConsoleApplication1
{
class Program
{
private static string baseUrl = ConfigurationManager.AppSettings["baseUrl"];
private static string accessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
private static string accessKey = ConfigurationManager.AppSettings["accessKey"];
private static string serviceVersion = ConfigurationManager.AppSettings["serviceVersion"];
static void Main(string[] args)
{
HttpClient client = new HttpClient();
string requestParameters = "AWSAccessKeyId=" + accessKeyId + "&Action=TopSites&Count=10&CountryCode=&ResponseGroup=Country&SignatureMethod=HmacSHA256&SignatureVersion=2&Start=1001&Timestamp=" + Amazon.Util.AWSSDKUtils.FormattedCurrentTimestampISO8601;
var signature = generateSignature(requestParameters);
var url = "http://" + baseUrl + "?" + requestParameters + "&Signature=" + signature;
HttpResponseMessage message = client.GetAsync(url).Result;
Console.ReadKey();
}
private static string generateSignature(string queryParameters)
{
string stringToSign = "GET\n" + baseUrl + "\n/\n" + queryParameters;
var bytesToSign = Encoding.UTF8.GetBytes(stringToSign);
var secretKeyBytes = Encoding.UTF8.GetBytes(accessKey);
var hmacSha256 = new HMACSHA256(secretKeyBytes);
var hashBytes = hmacSha256.ComputeHash(bytesToSign);
var signature = System.Net.WebUtility.UrlEncode(Convert.ToBase64String(hmacSha256.Hash));
Trace.Write("String to sign:{0}", signature);
return signature;
}
}
}
Request generated (from Fiddler):
GET http://ats.amazonaws.com/?AWSAccessKeyId=REMOVED&Action=TopSites&Count=10&CountryCode=&ResponseGroup=Country&SignatureMethod=HmacSHA256&SignatureVersion=2&Start=1001&Timestamp=2014-11-20T16:57:52.422Z&Signature=vdKOQYRmoJJL3ecY9GAzmGKHAXevoli6rGcEotGFaNY%3D HTTP/1.1
Host: ats.amazonaws.com
Connection: Keep-Alive
Response:
HTTP/1.1 403 Forbidden
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
Date: Thu, 20 Nov 2014 16:57:52 GMT
16d
SignatureDoesNotMatchThe request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.84291dc8-a35e-7dc3-7cc1-56fe20b5b236
0
Based on Darrel's comment and extensive comparisons between requests from the Java app and my sample app I've been able to correctly query the services using a number of requests including the sample one above. It would appear to have been a problem whereby the request string which is signed had an erroneous space character in front of the hostname, for added resiliency I am using the Amazon AWS SDK for .Net to perform the Url Encoding against their requirements to ensure the encoding is correct.
Here's the working sample code:
using System;
using System.Configuration;
using System.Diagnostics;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
private static string baseUrl = ConfigurationManager.AppSettings["AlexaServiceUrl"];
private static string accessKeyId = ConfigurationManager.AppSettings["AlexaAccessKeyId"];
private static string accessKey = ConfigurationManager.AppSettings["AlexaAccessKey"];
private static string serviceVersion = ConfigurationManager.AppSettings["AlexaServiceVersion"];
static void Main(string[] args)
{
HttpClient client = new HttpClient();
string requestParameters = "AWSAccessKeyId=" + accessKeyId + "&Action=TopSites&Count=10&CountryCode=&ResponseGroup=Country&SignatureMethod=HmacSHA256&SignatureVersion=2&Start=1001&Timestamp=" + Amazon.Util.AWSSDKUtils.UrlEncode(Amazon.Util.AWSSDKUtils.FormattedCurrentTimestampISO8601, false);
var signature = generateSignature(requestParameters);
var url = "http://" + baseUrl + "/?" + requestParameters + "&Signature=" + signature;
HttpResponseMessage message = client.GetAsync(url).Result;
Console.ReadKey();
}
private static string generateSignature(string queryParameters)
{
string stringToSign = String.Format("GET{0}{1}{2}/{3}{4}", "\n", baseUrl, "\n", "\n", queryParameters);
var bytesToSign = Encoding.UTF8.GetBytes(stringToSign);
var secretKeyBytes = Encoding.UTF8.GetBytes(accessKey);
var hmacSha256 = new HMACSHA256(secretKeyBytes);
var hashBytes = hmacSha256.ComputeHash(bytesToSign);
var signature = Amazon.Util.AWSSDKUtils.UrlEncode(Convert.ToBase64String(hmacSha256.Hash), false);
Trace.Write("String to sign:{0}", signature);
return signature;
}
}
}
Hope this helps someone else too.

Categories

Resources