I have been working with Direct Line for a long time, but I'm confused when refreshing tokens. I send a request like:
curl --location --request POST 'https://directline.botframework.com/v3/directline/tokens/refresh' --header 'Authorization: Bearer xxxxx'
And according to the documentation here, it should return a conversation object (described here), that should contain (amongs others) streamUrl and referenceGrammarId (as it does in generate token), but I don't get them in the response, I get just conversationId, token and expires_in, making it more difficult to handle the token refresh.
Is this the expected behavior, or those missing properties should be present?
Yes, it was the expected behavior, said the technical team at Microsoft.
Related
When I start a GET request to https://youtube.googleapis.com/youtube/v3/search?part=snippet&channelId=*channelId*&order=viewCount&key=*apiKey* I am supposed to get the most viewed videos of the channel.
In the response's items array's first element is a 6 months old video with around 4k views.
On the channel's Youtube page if I sort by most viewed, the first one is 10 years old with 200k views.
Any idea why I do not get the correct results?
I double-checked, the channel id is correct.
Easy workaround:
Use my YouTube operationnal API, make a GET request to https://yt.lemnoslife.com/search?part=snippet&channelId=*channelId*&order=viewCount
A bit more complicated workaround:
curl -s 'https://www.youtube.com/youtubei/v1/browse?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8' -H 'Content-Type: application/json' --data-raw '{"context":{"client":{"clientName":"WEB","clientVersion":"2.9999099"}},"browseId":"CHANNEL_ID","params":"EgZ2aWRlb3MYASAAMAE="}'
Don't forget to replace CHANNEL_ID with the channelId you want the most viewed videos from.
If you need more than the first 30 results, grab the continuation token from the response of the request above and use the following command (and if you're still interested for more results use the last continuation token you got):
curl -s 'https://www.youtube.com/youtubei/v1/browse?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8' -H 'Content-Type: application/json' --data-raw '{"context":{"client":{"clientName":"WEB","clientVersion":"2.9999099"}},"continuation":"CONTINUATION_TOKEN"}'
Don't forget to replace CONTINUATION_TOKEN with the continuation token you got from the latest request reponse.
Note: don't pay attention to the key, it's not a Youtube Data API v3 key.
I am trying to post multipart/form-data in laravel using ixudra/curl that specify the data is application json. The problem Im facing right know is to assign the type for data and still make the header content type is multipart/form-data.
$contents = storage_path('app/curl.txt');
$dataJson = '{"bId":"79", "docId":"23"}';
$response = Curl::to($url)
->withHeaders( array(
'Authorization: Bearer 123432',
'grant_type: jwt-bearer' ) )
->withData( array ('data' => $dataJson ))
->withFile('file', $contents, 'text/*', 'curl.txt')
->containsFile()
->withResponseHeaders()
->returnResponseObject()
->post();
For the curl, it is like this. Somehow, the error is "Failure to Authenticate OAuth Token" and the header content type is not multipart/form-data
curl -v -H "Authorization:Bearer 123432"
-H "grant_type:jwt-bearer"
-F "file=#\"/jet/app/www/default/test/storage/app/curl.txt\""
-F "data={\"bId\":\"79\", \"docId\":\"23\"};type=application/json"
"https://url/private"
Any idea? thanks for your time.
is this still an issue? Looking at your code, I don't see any errors in there. You don't need to include the containsFile() method in there but that's really a detail that won't effect your result in any way.
Based on your description, I doubt that the file has anything to do with the error. I'd recommend trying to make sure if the authentication is correct by using it on a simple GET request, just to make sure. If that works, you should dig deeper into the form.
Any way to figure out tricks to login to an API by Dexcom? This article discusses an approach for accessing blood sugar values but the first step is to log into the API and it is unclear how that step was taken as this is an undocumented API.
We are trying to help a diabetic get access to her blood sugar values so she can code new insulin dosing algorithms. (She wants to prevent the crashes and spikes in her blood sugars that ruin her days and put her at risk for blindness and being on dialysis. She believes and hopes human + machine can do better than her alone.)
If we are able to login the next steps for retrieving the values seem clear:
curl -k -X POST "https://share1.dexcom.com/ShareWebServices/Services/Publisher/ReadPublisherLatestGlucoseValues?sessionID=GUID&minutes=1440&maxCount=1" -H "Accept: application/json" -H "Content-Length: 0"
Is there anything to try that could give us a clue as to how take the first step and login to this API?
Open the Dexcom clarity website
In your browser (let's assume Chrome for now) open the developer tools and go to the "Network" tab
Select the "data" XHR call. This is the "hidden API call" that populates the graphs in the Dexcom Clarity.
Right click and select "Copy > Copy as CURL (bash)". That will give you the CURL code that authenticates and logs into the website.
(Optional) Take the CURL command and paste it to https://curl.trillworks.com/ to translate the CURL code into some
other language
curl 'https://clarity.dexcom.com/api/subject/1522320180078ZZZZZZ/analysis_session/1560634749054XXXXXXX/data' -H 'Origin: https://clarity.dexcom.com'
-H 'Accept-Encoding: gzip, deflate, br'
-H ..... -H 'Referer: https://clarity.dexcom.com/' -H --data-binary '{"localDateTimeInterval":["2016-05-01/2016-07-29"]}' --compressed
Notice that you can change the data range by changing the values passed at localDateTimeInterval and get access to the full data in the account at a resolution of 5-min measurements. The returned JSON also includes all other events, such as calibrations, etc.
I am playing with the open data project at spogo.co.uk (sport england).
See here for a search example: https://spogo.co.uk/search#all/Football Pitch/near-london/range-5.
I have been using cygwin and curl to POST JSON data to the MVC controller. An example is below:
curl -i -X POST -k -H "Accept: application/json" -H "Content-Type: application/json; charset=utf-8" https://spogo.co.uk/search/all.json --data '{"searchString":"","address": {"latitude":55,"longitude":-3},"page":0}'
Question:
How can I find out what other variables can be included in the post data?
How can I return all results, rather than just 20 at a time? Cycling through page numbers doesn't deliver all at once.
AJAX is simply a technique of posting data over a connection asynchronously, JSON is just a string format that can contain data. Neither of which have built in mechanisms for querying information such as what fields are accepted or the amount of data returned.
You will want to check the web service documentation for on spogo.co.uk for these answers, IF their web service exposes such functionality they will be the final authority on what the commands and formats are.
the api I'm working with is here:
I'm able to log in fine and get back an auth token, but cant figure out how to do anything that requires a token. I get back a forbidden response when I try to get or post a private URL.
they give an example of the request that needs to be sent using curl:
curl \
--header 'Authorization: UserLogin token="kk5lvKJG1FohVbS3kcHllyTshdcBKX4FpFAKFnx_Eh0IYYpXN3Hg6HZLceXuYt7V52mCcdUk5i_GUMc~"' \
-X POST \
'https://api.smarkets.com/v1/users/renew'
My question is: how would one send an equivalent request using the RestClient library in Ruby? I have a feeling that i'm messing up the header because the header in RestClient is all {:key => 'value'} pairs and I don't see how that would translate to the header given in the example.
In an HTTP request, headers are key/value pairs separated by a :, so the header pair that you need to send is:
:authorization => 'UserLogin token="kk5lvKJG1FohVbS3kcHllyTshdcBKX4FpFAKFnx_Eh0IYYpXN3Hg6HZLceXuYt7V52mCcdUk5i_GUMc~"'
So, to reproduce the request you give in your example:
RestClient.post 'https://api.smarkets.com/v1/users/renew', '', :authorization => 'UserLogin token="kk5lvKJG1FohVbS3kcHllyTshdcBKX4FpFAKFnx_Eh0IYYpXN3Hg6HZLceXuYt7V52mCcdUk5i_GUMc~"'