I'm trying to use OVH API to update DNS zone entries.
I'm using shell script with cURL command but I get this error :
{"message":"Invalid signature","httpCode":"400 Bad Request","errorCode":"INVALID_SIGNATURE"}
Here is the script :
OVH_CONSUMER_KEY="XXXXX"
OVH_APP_KEY="XXXXX"
OVH_APP_SECRET="XXXXX"
HTTP_METHOD="POST"
HTTP_QUERY="https://api.ovh.com/1.0/domain/zone/domaine.fr/record"
HTTP_BODY=""
TIME=$(curl -s https://api.ovh.com/1.0/auth/time)
CLEAR_SIGN="$OVH_APP_SECRET+$OVH_CONSUMER_KEY+$HTTP_METHOD+$HTTP_QUERY+$HTTP_BODY+$TIME"
SIG='$1$'$(echo -n $CLEAR_SIGN | openssl dgst -sha1 | sed -e 's/^.* //')
curl -X $HTTP_METHOD \
$HTTP_QUERY \
-H "Content-Type:application/json;charset=utf-8" \
-H "X-Ovh-Application:$OVH_APP_KEY" \
-H "X-Ovh-Timestamp:$TIME" \
-H "X-Ovh-Signature:$SIG" \
-H "X-Ovh-Consumer:$OVH_CONSUMER_KEY" \
-d '{"fieldType":"TXT", "subDomain":"", "target":"VX=SPF"}'
But with this script works fine :
OVH_CONSUMER_KEY="XXXXX"
OVH_APP_KEY="XXXXX"
OVH_APP_SECRET="XXXXX"
HTTP_METHOD="GET"
HTTP_QUERY="https://api.ovh.com/1.0/domain"
HTTP_BODY=""
TIME=$(curl -s https://api.ovh.com/1.0/auth/time)
CLEAR_SIGN="$OVH_APP_SECRET+$OVH_CONSUMER_KEY+$HTTP_METHOD+$HTTP_QUERY+$HTTP_BODY+$TIME"
SIG='$1$'$(echo -n $CLEAR_SIGN | openssl dgst -sha1 | sed -e 's/^.* //')
curl -X $HTTP_METHOD \
$HTTP_QUERY \
-H "Content-Type:application/json;charset=utf-8" \
-H "X-Ovh-Application:$OVH_APP_KEY" \
-H "X-Ovh-Timestamp:$TIME" \
-H "X-Ovh-Signature:$SIG" \
-H "X-Ovh-Consumer:$OVH_CONSUMER_KEY"
The differences between these 2 scripts are :
HTTP_METHOD
HTTP_QUERY
DATA
Do you have an idea why?
Thanks
L.
Solution found below:
OVH_CONSUMER_KEY="XXXXX"
OVH_APP_KEY="XXXXX"
OVH_APP_SECRET="XXXXX"
HTTP_METHOD="POST"
HTTP_QUERY="https://api.ovh.com/1.0/domain/zone/domaine.fr/record"
txt_type="TXT"
txt_field=""
txt_value='"XXXXXXXXXXXXXXX"'
HTTP_BODY="{"fieldType":"$txt_type","subDomain":"$txt_field","target":"$txt_value"}"
TIME=$(curl -s https://api.ovh.com/1.0/auth/time)
CLEAR_SIGN=$OVH_APP_SECRET"+"$OVH_CONSUMER_KEY"+"$HTTP_METHOD"+"$HTTP_QUERY"+"$HTTP_BODY"+"$TIME
SIG='$1$'$(echo -n $CLEAR_SIGN | openssl dgst -sha1 -hex | cut -f 2 -d ' ' )
curl -X $HTTP_METHOD \
$HTTP_QUERY \
-H "Content-Type: application/json" \
-H "X-Ovh-Application: $OVH_APP_KEY" \
-H "X-Ovh-Timestamp: $TIME" \
-H "X-Ovh-Signature: $SIG" \
-H "X-Ovh-Consumer: $OVH_CONSUMER_KEY" \
--data "$HTTP_BODY"
Related
I need to understand how to upload a file in chunks in azure file storage
File size: 580B
Creation:
fileName="bigfile.txt"
file_length=$(wc -m < $fileName)
request_date=$(TZ=GMT date "+%a, %d %h %Y %H:%M:%S %Z")
# Create
curl "https://xxxx.file.core.windows.net/test-fs/$fileName?sv=2021-06-08&ss=f&srt=sco&sp=rwdlc&se=2022-11-23T20:35:52Z&st=2022-11-23T12:35:52Z&spr=https&sig=xxxxxxxxxxxxxx" \
-X 'PUT' \
-H 'Content-Length: 0' \
-H "x-ms-date: $request_date" \
-H "x-ms-content-length: $file_length" \
-H 'x-ms-type: file' \
-H 'x-ms-version: 2021-06-08'
First chunk: OK added first 512 bytes
curl "https://xxxx.file.core.windows.net/test-fs/$fileName?sv=2021-06-08&ss=f&srt=sco&sp=rwdlc&se=2022-11-23T20:35:52Z&st=2022-11-23T12:35:52Z&spr=https&sig=xxxxxxxxxxxxxx&comp=range" \
-X 'PUT' \
-H "x-ms-range: bytes=0-511" \
-H 'x-ms-version: 2021-06-08' \
-H 'x-ms-write: update' \
-H "Content-Length: 512" \
-T "$fileName"
Second chunk: KO. It's adding not the remaining bytes but the first 68 bytes
curl "https://xxx.file.core.windows.net/test-fs/$fileName?sv=2021-06-08&ss=f&srt=sco&sp=rwdlc&se=2022-11-23T20:35:52Z&st=2022-11-23T12:35:52Z&spr=https&sig=xxxxxxxxxxxxxx&comp=range" \
-X 'PUT' \
-H "x-ms-range: bytes=512-579" \
-H 'x-ms-version: 2021-06-08' \
-H 'x-ms-write: update' \
-H "Content-Length: 68" \
-T "$fileName"
hello i'm trying this guide but it fail all time
https://github.com/ubahnverleih/WoBike/blob/master/Beam.md
To login, I need to get OTP code but i can't access to it
curl -d "phoneNumber=[phonenumber]countryCode=+[countrycode]" \
-H "Content-Type:application/json" \
-H "User-Agent:escooterapp/latest-app-version;ios" \
-X POST https://gateway.ridebeam.com/api/auth/phoneverification
but it sends message like this
{"success":false,"message":"There was some error","response":{},"error":"","data":{}}
i don't know why this fail
is my code grammarly wrong?
The tutorial and the curl command say it's an application/json and you are passing an incorrect format in the data. Pay attention at the beginning of the command curl -d ...
Correct:
curl -d '{"phoneNumber":"<phone-number>","countryCode":"+<country-code>"}' \
-H "Content-Type:application/json" \
-H "User-Agent:escooterapp/latest-app-version;ios" \
-X POST https://gateway.ridebeam.com/api/auth/phoneverification
Wrong:
curl -d "phoneNumber=[phonenumber]countryCode=+[countrycode]" \
-H "Content-Type:application/json" \
-H "User-Agent:escooterapp/latest-app-version;ios" \
-X POST https://gateway.ridebeam.com/api/auth/phoneverification
Execution:
curl -d '{"phoneNumber":"123123123","countryCode":"+55"}' \
-H "Content-Type:application/json" \
-H "User-Agent:escooterapp/latest-app-version;ios" \
-X POST https://gateway.ridebeam.com/api/auth/phoneverification
{"message":"PhoneVerificationServiceErrorDomain","messageKey":1,"messageArgs":"{"status":400,"message":"Invalid
parameter To:
+55123123123","code":60200,"moreInfo":"https://www.twilio.com/docs/errors/60200"
How I can convert the below code in VB.net. Thank you in advance.
$ curl -X POST https://www.drillster.com/daas/oauth/token \
-d 'client_id=874a16d4ac764ce4a545f0cca4584c63' \
-d 'client_secret=5782b2e7532b48b5a0798f2ad6644614' \
-d 'grant_type=authorization_code' \
-d 'code=cIEL8h'
Is there a way to do:
salt '*' state.apply nginx test=True
through salt-api ?
I'm doing this:
curl -sSk http://salt:8000
-H 'Accept: application/x-yaml'
-H 'X-Auth-Token: token'
-d client=local
-d tgt='*'
-d fun=state.apply
-d arg=nginx
-d test=True
but it actually applies new state.
Thanks in advance!
what about curl -sSk http://salt:8000/run instead of curl -sSk http://salt:8000
and are you using \ at the end of each option?
otherwise it looks good, what version of salt are you running?
https://salt-sproxy.readthedocs.io/en/latest/salt_api.html <= good reading
Finally, I found a way to do state.apply through salt-api with test option.
All I needed was: -d arg='test='true''
Example of full request:
curl -sSk http://salt:8000 \
-H 'Accept: application/x-yaml' \
-H 'X-Auth-Token: token' \
-d client=local \
-d tgt='*' \
-d fun='state.apply' \
-d arg='nginx' \
-d arg='test='true''
Google Analytics's new "Core Reporting API" (version 3.0) "recommend[s] using OAuth 2.0 to authorize requests" (citation). Its documentation, though, is very unclear about how to do that. (It says "When you create your application, you register it with Google" (citation), but does a shell script count as an "application"?? If so, I should register the bash script at the "APIs Console", which doesn't give any guidance on how to do so.) Using Analytics' version 2.3, I run a bash script:
#!/bin/bash
# generates an XML file
googleAuth="$(curl https://www.google.com/accounts/ClientLogin -s \
-d Email=foo \
-d Passwd=bar \
-d accountType=GOOGLE \
-d source=curl-dataFeed-v2 \
-d service=analytics \
| awk /Auth=.*/)"
# ...
feedUri="https://www.google.com/analytics/feeds/data\
?ids=$table\
&start-date=$SD\
&end-date=$ED\
&dimensions=baz\
&metrics=xyzzy\
&prettyprint=true"
# ...
curl $feedUri --silent \
--header "Authorization: GoogleLogin $googleAuth" \
--header "GData-Version: 2" \
| awk # ...
How would I do something like this — a script that grabs whatever login token I need and sends it back — for the new Analytics?
(Incidentally, yes, I realize the results will be JSON, not XML.)
Here is a sample script
googleAuth="$(curl https://www.google.com/accounts/ClientLogin -s \
-d Email=$USER_EMAIL \
-d Passwd=$USER_PASS \
-d accountType=GOOGLE \
-d source=curl-accountFeed-v1 \
-d service=analytics \
| grep "Auth=" | cut -d"=" -f2)"
feedUri="https://www.googleapis.com/analytics/v3/data/ga\
?start-date=$START_DATE\
&end-date=$END_DATE\
&ids=ga:$PROFILE_ID\
&dimensions=ga:userType\
&metrics=ga:users\
&max-results=50\
&prettyprint=false"
curl $feedUri -s --header "Authorization: GoogleLogin auth=$googleAuth"