As per a standard ouath2.0 Authorization grant code glow. The code received in query can be used to get an access_token as well a refresh_token.
But I am not able to get refresh_token from vimeo. Just the access_token is being provided with the below curl
curl 'https://api.vimeo.com/oauth/access_token' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Referer: http://localhost:4200/vimeoCallback?code=0772xxxxsomeCode0003f7d818e207b' \
-H 'Authorization: Basic YTMtxxxbasicbase64(KEY:ID)XXXXUg==' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36' \
-H 'Content-Type: application/json' \
--data-binary '{"grant_type":"authorization_code","code":"0772xxxxsomeCode0003f7d818e207b","redirect_uri":"http://localhost:4200/vimeoCallback"}' \
Please suggest me what I need to get the refresh_token
Your message parameters look good - you just need to send them as form encoded data rather than as JSON - see this link for the syntax.
Related
I want to use a scripted approach (probably via) curl, to access some simple info from the drive api, like creation date. Essentially I want to script what I can do in their web interface: https://developers.google.com/drive/api/v3/reference/files/list.
I having been using a curl command that they expose in a query at the above link:
curl \
'https://www.googleapis.com/drive/v3/files?corpora=user&q=createdTime%20%3E%20%272021-11-23T12%3A00%3A00%27&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
I have created an API key for this purpose (unrestricted for now). And used this app to generate an access token: https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&client_id=735795831119-kcpkamhiaojavqrt67mti7thcaa6ce87.apps.googleusercontent.com
But I have spent hours chasing my tail over the 401 Invalid Credentials error. Any help on getting a more specific error message, or better way to do this seemingly simple query would be appreciated. Thanks!
The result of the link below is an Authorization code.
https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&client_id=735795831119-kcpkamhiaojavqrt67mti7thcaa6ce87.apps.googleusercontent.com
You need to exchange it to https://accounts.google.com/o/oauth2/token to generate an Access Token:
curl \
--request POST \
--data "code=[Authentcation code from authorization link]&client_id=[Application Client Id]&client_secret=[Application Client Secret]&redirect_uri=urn:ietf:wg:oauth:2.0:oob&grant_type=authorization_code" \
https://accounts.google.com/o/oauth2/token
The result of the curl above is something like this:
{
"access_token": "access token here",
"expires_in": 3599,
"refresh_token": "refresh token here",
"scope": "https://www.googleapis.com/auth/drive",
"token_type": "Bearer"
}
Now you have the access token, you can paste it in the code below alongside with your API key.
curl \
'https://www.googleapis.com/drive/v3/files?corpora=user&q=createdTime%20%3E%20%272021-11-23T12%3A00%3A00%27&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
Note:
Make sure you enable the Drive API in GCP
Application Client Id and Application Client Secret can be found after you created an OAuth 2.0 Client ID in GCP.
Reference:
DaImTo answer on How to connect to the Google Drive API using cURL.
We are creating a OneNote page using the below Graph endpoint. Several id attributes are present in the HTML content of this page.
POST .. groups/{group-id}/onenote/sections/{section-id}/pages
To get the OneNote page content again, we are using the below graph end point.
GET ..groups/{group-id}/onenote/pages/{page-id}/content?includeIds=true
In the case of one of our customers, when we get the page content, we don't see those id attributes that we added when creating the page. Other customers do not experience this problem.
We checked that we did not PATCH anything on that page before it started returning page content without id attributes.
In debugging, we noticed that if we create a OneNote page and get the page content immediately, we get the IDs back, but if we do it later, we don't.
Here are the details of the latest get request for that page content.
curl $'https://graph.microsoft.com/v1.0/groups/e07ccbcc-3464-4777-aa3a-466cc0db328c/onenote/pages/1-1ea50c06f867479a84ffa6a1f3710e0d\u002157-7b03c43d-87ff-4692-8664-d3a42822b7ed/content?includeIds=true' \
-H 'Connection: keep-alive' \
-H 'Cache-Control: no-cache' \
-H 'sec-ch-ua: "Chromium";v="92", " Not A;Brand";v="99", "Microsoft Edge";v="92"' \
-H 'Pragma: no-cache' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'Authorization: Bearer
-H 'client-request-id: 95a44839-0407-4fe7-b497-294c9375ea1f' \
-H 'Accept: application/json, text/plain, */*' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36 Edg/92.0.902.84' \
-H 'If-Modified-Since: Mon: 26 Jul 1997 05:00:00 GMT' \
-H 'Origin: https://app.boarddecisions.com' \
-H 'Sec-Fetch-Site: cross-site' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Referer: https://app.boarddecisions.com/' \
-H 'Accept-Language: en-GB,en;q=0.9,en-US;q=0.8' \
--compressed
Additional Details about ids -
In OneNote page content, for different table elements, we have id attributes.
Example -
<table border="1" data-type="tasks" id="meetingDecisionsTable" style="width:1080px">
......
</table>
We usually get these IDs back in the data-id attribute like below.
For one specific customer, we are not getting any data-id attribute in the page content. We are unable to reproduce this issue outside of the customer's environment. Therefore, it should be tracked with the request id provided above.
I need to stress test a link that works with curl command below:
curl "http://192.168.1.191:7007/api/v1/users/login" -H "Accept-Encoding: gzip, deflate" -H "Accept-Language: en-US,en;q=0.8,vi;q=0.6" -H "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -H "Connection: keep-alive" --data "username=test&password=test" --compressed
How can I implement stress test with LoadTest
I found the solution.
I created a file test.txt with content:
username=test&password=test&
After that, run test command:
loadtest "http://192.168.1.191:7007/api/v1/users/login" -n 1000 -c 5 -p test.txt -T 'application/x-www-form-urlencoded'
Please make note that you have to add '&' in the end of test.txt file. This is a issue of LoadTest. I have had a pull request to fix it at https://github.com/alexfernandez/loadtest/pull/63
I wanted to put a small library code to pub.dartlang.org
After calling pub publish, it asked me to Allow accessing my google account for sending files. After I allowed by going to the given browser link, it gave me this error in the command line:
Waiting for your authorization...
Authorization received, processing...
ProcessException: No such file or directory
Command: curl --dump-header /tmp/temp_dir1_CzMqQG/curl-headers --cacert /home/afsina/apps/dart/dart-sdk/util/pub/curl/ca-certificates.crt --request POST --location --max-redirs 5 --data-binary #- --header accept: --header user-agent: --header Content-Type: application/x-www-form-urlencoded; charset=UTF-8 --header content-length: 265 https://accounts.google.com/o/oauth2/token
here is the --verbose output
Looks great! Are you ready to upload your package (y/n)? y
IO : Read line: y
FINE: Loading OAuth2 credentials.
IO : Seeing if file /home/afsina/.pub-cache/credentials.json exists.
IO : File /home/afsina/.pub-cache/credentials.json does not exist.
FINE: No credentials found at /home/afsina/.pub-cache/credentials.json.
MSG : Pub needs your authorization to upload packages on your behalf.
| In a web browser, go to https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force&response_type=code&client_id=818368855108-8grd2eg9tj9f38os6f1urbcvsq399u8n.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A59097&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email
| Then click "Allow access".
|
| Waiting for your authorization...
MSG : Authorization received, processing...
FINE: Sending Curl request POST https://accounts.google.com/o/oauth2/token
IO : Begin create temp directory .
IO : End create temp directory .
IO : Spawning curl --dump-header /tmp/temp_dir1_RpLNu6/curl-headers --cacert /home/afsina/apps/dart/dart-sdk/util/pub/curl/ca-certificates.crt --request POST --location --max-redirs 5 --data-binary #- --header accept: --header user-agent: --header Content-Type: application/x-www-form-urlencoded; charset=UTF-8 --header content-length: 265 https://accounts.google.com/o/oauth2/token
IO : Spawning curl --dump-header /tmp/temp_dir1_RpLNu6/curl-headers --cacert /home/afsina/apps/dart/dart-sdk/util/pub/curl/ca-certificates.crt --request POST --location --max-redirs 5 --data-binary #- --header accept: --header user-agent: --header Content-Type: application/x-www-form-urlencoded; charset=UTF-8 --header content-length: 265 https://accounts.google.com/o/oauth2/token
ERR : ProcessException: No such file or directory
| Command: curl --dump-header /tmp/temp_dir1_RpLNu6/curl-headers --cacert /home/afsina/apps/dart/dart-sdk/util/pub/curl/ca-certificates.crt --request POST --location --max-redirs 5 --data-binary #- --header accept: --header user-agent: --header Content-Type: application/x-www-form-urlencoded; charset=UTF-8 --header content-length: 265 https://accounts.google.com/o/oauth2/token
I am guessing it cannot find the ca-certificates.crt file but not sure why.
Version Info: Dart SDK version 0.2.10.1_r16761
ubuntu linux 12.10 64 bit
My bad, this was because pub has "curl" dependency. After installing curl I could publish the lib.
If you run pub on Linux or Mac, it will assume curl is in your PATH and try to spawn it without an explicit path. On Windows, it will use the included curl binary. Our assumption here was that most *NIX users would have curl installed already.
This curl dependency should be going away soon anyway, but I'm glad you found the solution.
I'm sending json request via curl to my local web server
curl -H 'Content-Type: application/json' -d {"name":"Stanford University", "subdomain":"stanford"} http://localhost:3000/rest/v1/groups.json
But in my rails app in params i'm getting
Parameters: {"name"=>"Stanford University", "subdomain"=>"stanford", "group"=>{"name"=>"Stanford University", "subdomain"=>"stanford"}}
Where did that hash group came from, and how do i controll it?
Look in config/initializers/wrap_parameters.rb. You likely have wrap_parameters enabled for JSON requests.
You can disable this option in the above file with
wrap_parameters false
Recommended Reading: http://api.rubyonrails.org/classes/ActionController/ParamsWrapper.html
You have to send it into Json Format
Try Following
curl -H 'Content-Type: application/json' -d "{\"name\":\"Stanford University\", \"subdomain\":\"stanford\"}"
OR
hash = {"name":"Stanford University", "subdomain":"stanford"}
curl -H 'Content-Type: application/json' -d "#{hash.to_json}" http://localhost:3000/rest/v1/groups.json