第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Cosmos DB Azure 表 API oData 身份驗(yàn)證 REST/C#?

Cosmos DB Azure 表 API oData 身份驗(yàn)證 REST/C#?

C#
桃花長相依 2021-10-09 10:22:49
我正在嘗試使用 Table API 訪問 Azure Cosmos DB。挑戰(zhàn)是,盡管創(chuàng)建了 SharedKeyLite,服務(wù)器仍然返回 Unauthorized - 似乎 SharedKeyLite 不受支持,或者我生成的簽名或標(biāo)頭錯誤。這是代碼    static readonly string storageAccountName = "accountName";    static readonly string storageAccountKey = "xxxx";    static readonly string uri = "https://accountName.table.cosmosdb.azure.com/Contacts()";    static readonly string utc_date = DateTime.UtcNow.ToString("r");    static void Main(string[] args)    {        Console.WriteLine(GetResult().Result);    }    static async Task<string> GetResult()    {        // Set this to whatever payload you desire. Ours is null because         //   we're not passing anything in.        Byte[] requestPayload = null;        var requestDateString = DateTime.UtcNow.ToString("R", CultureInfo.InvariantCulture);        var requestUri = new Uri(uri);        DateTime now = DateTime.UtcNow;        //Instantiate the request message with a null payload.        using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri)        { Content = (requestPayload == null) ? null : new ByteArrayContent(requestPayload) })        {            ConstructHeaders(httpRequestMessage.Headers, requestDateString);            string authorizationHeader = GenerateSharedKeyLite(storageAccountKey, storageAccountName, uri,requestDateString);            httpRequestMessage.Headers.Authorization = new AuthenticationHeaderValue("SharedKeyLite", authorizationHeader);            // Send the request.            using (HttpResponseMessage httpResponseMessage = await new HttpClient().SendAsync(httpRequestMessage))            {                string json = await httpResponseMessage.Content.ReadAsStringAsync();                return json;            }        }    }這些是我添加的標(biāo)題,ConstructHeaders 方法的擴(kuò)展。請參閱此鏈接以獲取請求參數(shù)
查看完整描述

1 回答

?
慕絲7291255

TA貢獻(xiàn)1859條經(jīng)驗(yàn) 獲得超6個贊

只需復(fù)制您的代碼,它就可以在我身邊工作。如果您還沒有修改您的代碼,請確保您的storageAccountNamestorageAccountKey是正確的。

順便說一句,在方法中GenerateSharedKeyLite不需要canonicalizedResourceString為實(shí)體操作添加查詢參數(shù)。comp如果要操作表或服務(wù)的組件信息,則只需添加。請參閱構(gòu)建規(guī)范化資源字符串。

查詢字符串應(yīng)包括問號和comp參數(shù)(例如,?comp=metadata)。查詢字符串中不應(yīng)包含其他參數(shù)。


查看完整回答
反對 回復(fù) 2021-10-09
  • 1 回答
  • 0 關(guān)注
  • 221 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號