RESTful APIs for Azure Analytic Services not working - c#

Alright, I'll be straightfoward here. I successfully called Windows Azure Analytic Services's REST APIs for getting and setting the settings for Blob logging and metrics.
However, when I give it a go for tables and queues, I get the following error message:
AuthenticationFailed Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:9d4436e0-9367-46ed-9967-b3ebe888d2f8 Time:2012-01-16T09:20:09.5141262Z
The string I use to sign is the following:
GET\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:Mon, 16 Jan 2012 09:04:50 GMT\nx-ms-version:2011-0818\n/<accountname>/\ncomp:properties\nrestype:service. It works perfectly fine for Blobs.
The most troublesome thing is that I am not getting an AuthenticationErrorDetail in my response from Analytic Services. When I tried calling the settings REST APIs for Blobs, I actually got a AuthenticationErrorDetail that told me what string the server used to sign. That really helped me construct the above.
Has anyone else gone through something similar?

I realised that my REST calls worked for queues too. It did not work for tables, however.
http://msdn.microsoft.com/en-us/library/windowsazure/dd179428.aspx offered more information:
2009-09-19 Shared Key Lite and Table Service Format
This format supports Shared Key and Shared Key Lite for all versions
of the Table service, and Shared Key Lite for the 2009-09-19 version
of the Blob and Queue services. This format is identical to that used
with previous versions of the storage services. Construct the
CanonicalizedResource string in this format as follows:
Beginning with an empty string (""), append a forward slash (/),
followed by the name of the account that owns the resource being
accessed.
Append the resource's encoded URI path. If the request URI addresses a
component of the resource, append the appropriate query string. The
query string should include the question mark and the comp parameter
(for example, ?comp=metadata). No other parameters should be included
on the query string.
In the end, it accepted the path ?comp=properties.

I encountered similar problems - blobs working fine, tables not working - when I incorrectly used DateTime.Now instead of DateTime.UtcNow for x-ms-date header

Related

signature verification failed; please verify account number and chain-id: unauthorized

You don't want to know how many hours I've spent trying to figure this one out.
I'm trying to send a broadcast to the Cosmos Blockchain, via the Terra Pisco/Rebel1 Api.
LUNA2: https://pisco-lcd.terra.dev/swagger/#/
LUNC: https://rebel1.grouptwo.org/swagger/#/
When I run the simulation Api, the transaction works perfectly.
However when I run a transaction just via the standard api, it fails with a "signature verification failed" error.
This issue is related to the signature being passed to Cosmos not containing the correct Chain-Id or Sequence Number. However I've confirmed that the base64 has it. And all the payloads being sent are correct (Protobuf & Rest JSON), according to the Cosmos SDK support team.
I have generated an issue in the cosmos-sdk repo below (it contains all the details, models, dtos, protos, I pass cosmos):
https://github.com/cosmos/cosmos-sdk/issues/14789
I've verified the Protobuf data according to terra-money's terra.js library
https://github.com/terra-money/terra.js. And the data looks correct.
I've also confirmed that the signature contains the correct Chain-Id & Sequence number.
This issue is related to the C# SDK that I'm currently building. It allows users to broadcast Tx data to Terra (Cosmos).
Here's the link, if you want to generate a PR:
https://github.com/TerraMystics/terra-sharp

AuthBot with Azure Table Store

I'm using authbot (AuthBot) to login users on my bot, but, I'm using a large amount of data, and since than, it starts gives me an error that I'm overload (Stackoverflow)
So, I do as suggested, I create an Azure Table Storage, since than, my bot does not recognize the authentication. It seems Authbot cannot get \ set the data from table storage. Do you know something about it?
The current AuthBot uses the default state client. I've submitted a PR to fix this: https://github.com/MicrosoftDX/AuthBot/pull/37/files
In the interim, you can download the AuthBot source and include the changes to OAuthCallbackController in your project.
Edit:
This repo will eventually replace AuthBot: https://github.com/richdizz/BotAuth It is already using the correct state client interfaces.

How can I construct canonical resource for Azure Storage Table Set Table Service Properties endpoint?

Azure exposes an endpoint to set table service properties. This endpoint expects client to pass Authorization header and that could be formatted as SharedKeyLite <account-name>:<signature> for Table services as explained here. signature is the sha256 encoded form of <date>\n<canonical-resource> for which canonical resource construction follows the rules:
Beginning with an empty string (""), append a forward slash (/), followed by the name of the account that owns the resource being
accessed.
Append the resource's encoded URI path. If the request URI addresses a component of the resource, append the appropriate query
string. The query string should include the question mark and the comp
parameter (for example, ?comp=metadata). No other parameters should be
included on the query string.
according to Authentication documentation.
I am able to authenticate for query tables or entity operations. However, I am consistently failing to authenticate for set table service properties endpoint. I construct canonical resource by starting with "/<account-name>" according to rule 1 and then I append another "/" without any query string, because I believe request URI (which is https://<account-name>.table.core.windows.net/?restype=service&comp=properties) is not addressing a component according to rule 2. That makes canonical resource "/<account-name>/".
Is there anybody managed to authenticate for this endpoint at all? If so how?
NOTE 1: I tried otherwise (appended query string too and that made the canonical resource "/<account-name>/?comp=properties"), but failed again.
NOTE 2: Rule 2 asks to append encoded URI path, but that is not really the case.
I was able to partially resolve the issue. The problem is Azure storage emulator behaves different than the actual storage service. Set Table Service Properties endpoint is not authenticating the request on the emulator whereas it goes through fine on the service itself. Other requests against table (read, create, delete) and entities (create, read, update and delete) are behaving same on emulator and service.
The canonical resource is formatted as "/<account-name>/?comp=properties". Content type makes no difference in authentication as expected.

how to get the project specific jira issues using jira rest api in .net?

I have a requirement where i need to get all the issues for a particular project in jira so for this i have created a console application which has rest client class using which I make a GET request call and for testing purpose rest api url is
"https://jira.atlassian.com/rest/api/latest/issue/JRA-9"
using this url i make a HttpWebRequest and get the response back in json formated string. Now this json string contain all the issue specific information but my actual requrement is to get all the project specific issues.
I tried to find out if i get any project specifc URL for testing purpose from where i get json reply back and I found http://kelpie9:8081/rest/api/2/search?jql=project=QA+order+by+duedate&fields=id,key but for this i get the "The remote name could not be resolved: 'kelpie9'" error.
Could you please help me in this?
`
JIRA's REST API does not appear to currently support any project-based queries separate from their search API.
You can specify a specific project in the search by using the JQL. Given that you know a project (e.g., "JRA" in "JRA-9"), then you can quickly search through all of its issues:
Working result: https://jira.atlassian.com/rest/api/latest/search?jql=project=JRA
One important note is that the results return actual total versus what is actually returned:
"startAt":0,"maxResults":50,"total":30177
You can add query string variables to the request to get more (or less) results. You can also control the fields related to issues to retrieve as well: https://jira.atlassian.com/rest/api/latest/search?jql=project=JRA&startAt=75&maxResults=75 (slower the more you request, and probably not nice to hit their public servers with big numbers).
You can even POST a JSON object that represents the query (slightly tweaked from the linked search docs):
{"jql":"project = JRA","startAt":75,"maxResults":75,"fields":["id","key"]}
Of interest, and as part of the JQL, you can sort the results by any field. Just add " order by id" to the project name, as-in "jql=JRA+order+by+id" in the querystring or "jql": "project = JRA order by id" in the POSTed JSON body.
Note: Above is the actual answer to the real question. However, the literal question is the cause of the `The remote name could not be resolved: 'kelpie9' error.
Their documentation shows kelpie9 as an example server name that they are testing on internally, running on port 8081. Your computer is not aware of a server/machine named kelpie9, as it does not publicly exist. Replace kelpie9 with whatever your JIRA server's hostname is internally and 8081 with whatever port it is using (or remove it if you do not see one when you view JIRA on your intranet site, which means port 80 for http and port 443 for https). For example, many companies run it a "https://jira/". You would replace the example link with https://jira/rest/api/2/search?jql=project=QA+order+by+duedate&fields=id,key.

Google-drive example: oauth2callback not found

I need a little help with the C# example program of Google-Drive...
I used this so-called "tutorial"/"example":
https://developers.google.com/drive/examples/dotnet
And the code from here:
https://code.google.com/p/google-drive-sdk-samples/source/checkout
I uploaded my (only slightly modified) sourcecode here in case anybody doesn't have Mercurial (I didn't have Mercurial and no admin rights to install it either, and Mercurial is the only way to get the sourcecode...):
http://verzend.be/elt0k13enraw/DrEdit.rar.html
I always get
"Ressource cannot be found"
Requested URL: /oauth2callback
I don't find this astonishing, as no oauth2callback controller or handler is implemented...
I tried adding a Controller called oauth2callbackController and redirecting to another action in oauth2callbackController.Index, doing
return new RedirectResult("/about/about");
But that only creates a NULL-reference exception.
So i figured, maybe the wrong controller and redirected to
return new RedirectResult("/drive/Index");
But that only creates an infinite loop of redirect -> allow -> redirect - allow -> etc.
BTW, the config to change the API key + REDIRECT_URI is in
Models\ClientCredentials.cs
Note:
The problem aren't my modifications.
The sample also didn't work unmodified, with the exact same error.
All I did was removing EntityFramwork references, and throwing "Not implemented exception" when a method using entity was called.
Edit:
Additional information:
What I really wanted to do in the first place is to write a console service that exports my database, LZMA-compresses the exported content, encrypts that with OpenPGP, and uploads the database of my server to Google drive every day at 24:00 o'clock, without any user input.
I got export working without a problem, i got the LZMA compression working without a problem, I got the encryption with PGP working without a problem.
After the end of the working day (grrrr), when I was at home, I was even able to download the example-code with the mercurial installed on my Linux-machine at home, and bring it on the windows machine using SMB...
But now I can't get the sample for the Google-drive SDK working...
And moreover, what I really need is an example for a console service/daemon, not a web-application.
When I created the API key, I saw one could create a key for a service, but there is no example on how to write a Google-Drive service (console application), and no useful documentation as well (yea there is a reference, but it's only a reference, IntelliSense provides about the same)...
When configuring your app in the API Access tab of the APIs Console, you had to set the root (/) of your web server as the redirect URI and not /oauth2callback.
Assuming that your app is published at www.example.com, just go back to the APIs Console and set it to www.example.com instead of www.example.com/oauth2callback

Categories

Resources