Azure blob storage - using a SAS url for a blob file with ajax request returns 400 - azure-blob-storage

I'm using a (working) SAS url to retrieve a file from azure blob storage using AJAX. I've enabled CORS in my Azure storage account and now I'm getting a 400 error:
Authentication information is not given in the correct format. Check the value of Authorization header.
The url works if I just paste it into a browser's address bar.

Related

Google Drive File download through Oauth2

I am getting below error while using Google API.
URL:
https://docs.google.com/feeds/download/documents/export/Export?id=${document_id}&exportFormat=${format}&format=${format}
Method: GET
Result format: File
Error:
Unauthorized (401) - The request requires user authentication (1 attempt)
we retrieve access token with help of refresh_token, client_id and client_secret key
while externally (except RunMyProcess portal) received 307 status code
Temporary Redirect (307) - The requested resource resides temporarily under a different URI
we just wanted to clarify about API. Is this API has been changed?
Cannot find Google API documentation for same.

Trying to get downloadable url of the SharePoint file of the attachments shared in the teams/channel chat

We are trying to access the SharePoint url of the attachments shared in the teams/channel chat and for the teams meeting recording.
We have used Oauth2 to retrieve the auth token and using Microsoft graph api to get the downloadable/public url for the same
making a GET request with token in the request header still returns 401 Unauthorised error
Although we are able to get the downloadable url if we use site-id , list-id and item-id in the GET request https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item}/driveitem
But these are not available when our message extension app is invoked from a message
Posting the Answer for better knowledge
Copying from #Saonti comments
Using Graph API explorer are you able to get the drive item with this API graph.microsoft.com/v1.0/sites/%7Bsite-id%7D/lists/… ? Or you are getting error?

Clarification for FineUploader blobUri property uploading to Azure

I'm setting up React version of FineUploader to upload files to Azure going through the docs and I could use a bit more clarification on bloburi sent to my API when requesting a SAAS.
We're requesting the SAAS before uploading the file which is why I'm confused.
Say, I'm uploading a file named my-image.jpg into my blob container with the endpoint of https://myaccount.blob.core.windows.net/my-container on Azure.
I also want to rename the file during upload by calling a function and let's assume the function returns 89056c3d-7bb3-my-image.jpg for file name.
Would then https://myaccount.blob.core.windows.net/my-container/89056c3d-7bb3-my-image.jpg be the bloburi I send to my API while requesting a SAAS?
In other words, are we constructing the bloburi using the azure blob storage container URI and the file name we'll end up using?
If I'm interpreting this correctly, what happens if the user is uploading multiple files? What would be the blobUri I'd have to send to request a SAAS?
UPDATE:
When my request hits my backend API to get a SAS, the blobUri comes in as /server/upload/some-guid-value.txt. I'm using the following options when instantiating an uploader. What am I doing wrong?
const uploader = new FineUploaderAzure({
options: {
signature: {
endpoint: 'http://localhost:4879/api/getsas'
},
request: {
containerUrl: 'https://myaccount.blob.core.windows.net/my-container'
},
uploadSuccess: {
endpoint: 'http://localhost:4879/success'
}
}
})
In other words, are we constructing the bloburi using the azure blob storage container URI and the file name we'll end up using?
Correct. Fine Uploader Azure constructs this for you. Be sure to verify permissions (considering the _method param that accompanies the Blob url) before returning a signature.

Onedrive File picker not opening when using authorization code flow

I am following the Microsoft onedrive documentation authorization code flow to grant my user access to their onedrive files.
I got the access_code and sent a POST request using ruby with access_code, client_id, clien_secret and got the access_token as a JSON response.
when I try appending this access_token,scopes,state,.. along with My Redirect_url to access the Onedrive file Picker the window closes. The following is the sample URL of that
http://MY_REDIRECT_URL/onedrive#access_token=My_access_token&token_type=bearer&expires_in=3600&scope=wl.skydrive%20wl.signin&state=redirect_type%3dauth%26display%3dpage%26request_ts%3d1427963180884%26response_method%3durl%26secure_cookie%3dfalse&user_id=My_USER_ID
when I used the same URL in Authorization token flow it's properly opening the file picker.
When I checked the wl_auth cookie value it's saying
error=invalid_cookie&error_description=The%20'wl_auth'%20cookie%20has%20been%20modified%20incorrectly.%20Ensure%20that%20the%20redirect%20URI%20only%20modifies%20sub-keys%20for%20values%20received%20from%20the%20OAuth%20endpoint.&status=connected
The error is that we need to make the URL the same as the URL that would be obtained when Authorization token flow is used.
Also, while making URL make sure its encoded and also response_type value should be URL not COOKIE

Can you make a CORS Google API request without OAuth?

I would like to make a Google API request from the client instead of the server, in order to save time and load on the server. This page explains using OAuth for CORS, when you want to access a user's private data. I don't want a user's Google data, and don't want users authenticating to their Google account.
The fact that I can get a browser API key makes me think that this is possible, but when I do this:
$.get 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?',
key: browser_key
location: "#{lat},#{lon}"
radius: '300'
sensor: true
I get "No 'Access-Control-Allow-Origin' header is present on the requested resource."
Using the JS client works. I gave an HTML node to the PlacesService constructor instead of a map.
https://developers.google.com/maps/documentation/javascript/places

Resources