Since last week, the catalog search on Mendeley API is giving me the following result:
{
"message": "Client ID <client_id> is not allowed",
"status": 403
}
I am using standard code in Python that worked before:
mendel = Mendeley(client_id=client_id, client_secret=client_secret)
auth = mendel.start_client_credentials_flow()
session = auth.authenticate()
print(session.catalog.search('Nitrogen dynamics', view='all').list(50).items)
And I have the same result using curl:
curl -X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-u client_id:client_secret \
-d "grant_type=client_credentials&scope=all" \
https://api.mendeley.com/oauth/token
curl -X GET "https://api.mendeley.com/search/catalog?access_token={access_token}"
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.
The following connects to the API's server
httparty -a post -H Content-Type:application/json "https://test.co.uk/interface/search"
and returns an error message (which is by design).
However, if another header is added:
httparty -a post -H Content-Type:application/json -H Accept-Encoding:gzip,deflate "https://test.co.uk/interface/search"
an error occurs in the ruby JSON parser
.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/json-2.1.0/lib/json/common.rb:156:in
`parse': 765: unexpected token at '' (JSON::ParserError)
No amount of escaping with quotes changes the situation.
httparty -a post -H 'Content-Type:application/json' -H Accept-Encoding:gzip,deflate "https://test.co.uk/interface/search"
same error...
On the other hand, if one excludes the 'application/json' header, multiple headers can be submitted, obtaining a server response (same error message from API server).
httparty -a post -H Accept-Encoding:gzip,deflate -H Content-Length:578 -H Host:test.co.uk -H Connection:Keep-Alive "https://test.co.uk/interface/search"
How can multiple headers be submitted, with the 'application/json' string pass ruby's JSON parsing filter?
Personally I use HTTPie, try to curl like this way.
curl -H "Accept-Encoding:gzip,deflate" \
-H "Content-Length:578" \
-H "Host:test.co.uk" \
-H "Connection:Keep-Alive" \
-X POST \
"https://test.co.uk/interface/search"
I create docker image for testing in my Jenkins pipeline, uploading this to Docker hub and deploy those to Kubernetes. At the end of the testing process, I want to delete the test image from Docker hub (not from test machine). How do I delete docker hub image from command line?
Use the Docker Hub API as documented in:
https://docs.docker.com/v1.7/reference/api/docker-io_api/#delete-a-user-repository
I've just tested a delete of a test image with curl:
curl -X DELETE -u "$user:$pass" https://index.docker.io/v1/repositories/$namespace/$reponame/
Replace $user and $pass with your user and password on the Docker Hub, respectively; and replace $namespace (in my case it's the same as the $user) and $reponame with the image name (in my case was test).
You can delete any <TAG> from your Docker Hub <REPO> by using curl and REST API to the Docker Hub website (at https://hub.docker.com/v2/) rather that to the Docker Hub registry (at docker.io). So if you are not afraid of using an undocumented API, this currently works:
curl -i -X DELETE \
-H "Accept: application/json" \
-H "Authorization: JWT $HUB_TOKEN" \
https://hub.docker.com/v2/repositories/<HUB_USERNAME>/<REPO>/tags/<TAG>/
The HUB_TOKEN is a JSON Web Token passed using Authorization HTTP header, and it can be obtained by posting your credendials in JSON format to the /v2/users/login/ Docker Hub endpoint:
HUB_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"$HUB_USERNAME\", \"password\": \"$HUB_PASSWORD\"}" https://hub.docker.com/v2/users/login/ | jq -r .token)
2FA => Personal Access Token
Note than when you have 2FA enabled, you’ll need a personal access token (the only password accepted by the API when using 2FA).
Dockerhub has a REST backEnd, then you can use it... it is just skipping the FE...
For example:
export USERNAME=myuser
export PASSWORD=mypass
export ORGANIZATION=myorg (if it's personal, then it's your username)
export REPOSITORY=myrepo
export TAG=latest
curl -u $USERNAME:$PASSWORD -X "DELETE" https://cloud.docker.com/v2/repositories/$ORGANIZATION/$REPOSITORY/tags/$TAG/
This will delete one tag...
In my case, I have microservices, then the REPOSITORY = the Microservice Name...
If I want to delete all the older images, I can iterate on this....
For any PowerShell friends.
$params = #{username='mickey';password='minnie'}
$response = Invoke-RestMethod -Uri https://hub.docker.com/v2/users/login/ -Method POST -Body $params
$token = $response.token;
$orgName = "mickey" #organization or user name
$repoName = "disney"
$Uri = $("https://hub.docker.com/v2/repositories/$orgName/$repoName/")
Invoke-WebRequest -Method Delete -Uri $Uri -Headers #{Authorization="JWT " + $token; Accept= 'application/json' }
It is possible. For a shortcut, Open dev tools in Chrome, go to the network tab. Delete a tag manually from Docker Hub. You will see a request on the network tab in dev tools that goes to https://cloud.docker.com/v2/repositories//tags/. Just right click on that request, Copy, Copy as Curl. It should look something like this...
curl "https://cloud.docker.com/v2/repositories//tags//" -X DELETE -H 'Pragma: no-cache' -H 'Origin: https://cloud.docker.com' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36' -H 'Accept: application/json' -H 'Cache-Control: no-cache' -H 'Referer: https://cloud.docker.com/user/repository/registry-1.docker.io/reponame/tags' -H 'Cookie: ' --compressed
You can now use the new BETA (as of 2022-01) Docker Hub API
https://docs.docker.com/docker-hub/api/latest/
and the docker-hub CLI tool among a few other options.
hub-tool login
hub-tool tag rm myrepo/myimage:mytag
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