REST call CDS Login for Serviio version 2
If I take the values from the REST docs, and create the user and password used in the example, the login completes as expected.
request.Headers.Add("authorization", "Serviio UserName=some user, Signature=qj8iVn3vTCQEnuaOzmPmVqxkF/c=")
But when I attempt to recreate the signature via code then I get the result as seen in the example
request.Headers.Add("authorization", "Serviio HKS3OvMF5qkM1BulBhAukntIGZU=")
Why does the example differ from the text? When I send the signature of HKS3OvMF5qkM1BulBhAukntIGZU= it fails.
Here is my code.
'user name
Login.TextBox1.Text = "some user"
'password
Login.TextBox2.Text = "password"
'Calculate a unique hashing string, which is an RFC 2104-compliant HMAC-SHA1 hash, using a string
'<username>:<password> (for example my user:password) And the user's password as the key. Convert the
'resulting value to base64.
'credential signature
Dim MyAuthorization = Convert.ToBase64String(System.Text.UnicodeEncoding.Default.GetBytes(Login.TextBox1.Text + ":" + Login.TextBox2.Text))
value returned:
c29tZSB1c2VyOnBhc3N3b3Jk
'create unique hashing key with users password
Dim mykey As HMACSHA1 = New HMACSHA1(System.Text.UnicodeEncoding.Default.GetBytes(Login.TextBox2.Text))
'hash value username:password encrypted with password
Dim nauth_signature = Convert.ToBase64String(mykey.ComputeHash(System.Text.UnicodeEncoding.Default.GetBytes(MyAuthorization)))
value returned:
t6pMIoHj4tMLjgpYDR7L4qzVr8M=
'data to hash
Dim ndata As String = "Thu, 14 Aug 2008 17:08:48 GMT"
'create new hash for ndata
Dim mykey2 As HMACSHA1 = New HMACSHA1(System.Text.UnicodeEncoding.Default.GetBytes(nauth_signature))
'hash value ndata (date) with key of nauth_signature
Dim auth_signature = Convert.ToBase64String(mykey.ComputeHash(System.Text.UnicodeEncoding.Default.GetBytes(ndata)))
value returned:
HKS3OvMF5qkM1BulBhAukntIGZU=