How to get a Yelp access token - api

I am trying to use the yelp fusion api but cannot seem to find out how to format the url. I have read the get started page but do not understand it. I just need to know where to put what. This is what I have so far:
https://api.yelp.com/oauth2/token?grant_type=client_credentials&client_id=ID&client_secret="CLIENT SECRET"
When I load this url it says "VALIDATION_ERROR." What am I doing wrong?

The grant_type,client_id and client_secret should be sent in application/x-www-form-urlencoded format in the POST call.
curl -X POST \
https://api.yelp.com/oauth2/token \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET'

Related

How do I perform this type of authentication in the postman

Good afternoon, everyone! Guys I'm going through a problem with basic authentication in Postman, I'll leave below details of what's going on. I need to send a Post so I can perform authentication and the server will return me a token bearer, but I'm taking a 400 error. I'll leave attached images of the Curl request and how I'm setting up in Postman.
Auth:
enter image description here
Body:
enter image description here
Reading the documentation I'm using I realized that I needed to perform a basic authentication using client_id and client_secret for me to be returned a token bearer, the same error is returned to me when I perform a request in curl. Could you help me with this mistake? Could you tell me where I'm going wrong?
Segue requisição curl:
curl -X 'POST' \
'https://portoapicloud-hml.portoseguro.com.br/oauth/v2/access-token' \
-H 'accept: application/json' \
-H 'Authorization: Basic NjZiNWJmMWI4MDE0NDExMWE1MGYwMWMyYmUxZjFiZDY6YzIwMGEwNzZlNmFkNDBkYThkYTkwODQ2YWI4OTI3MjU=' \
-H 'Content-Type: application/json' \
-d '{
"grant_type": "client_credentials"
}'

Authentication error using cloudflare api

I repeatedly received an authentication error just like this (not me) when using the Cloudflare api.
curl -X GET "https://api.cloudflare.com/client/v4/zones/<ZONEID>/dns_records?type=A&name=<DOMAIN>&content=127.0.0.1&proxied=undefined&page=1&per_page=20&order=type&direction=desc&match=all" \
-H "X-Auth-Email: <EMAIL>" \
-H "X-Auth-Key: <APITOKEN>" \
-H "Content-Type: application/json"
{“success”:false,“errors”:[{“code”:10000,“message”:“Authentication error”}]}
What am I doing wrong?
I was getting that exact same error message, and I found out that I was using the API Token instead of the API Key in the X-Auth-Key parameter.
Apparently the only way that seems to work is to use the user token instead of the zone one.
curl -XPOST -H 'X-Auth-Key: TOKEN' -H 'X-auth-email: EMAIL' -H \"Content-type: application/json\" -d '{\"type\":\"CNAME\",\"name\":\"hi\",\"content\":\"example.com\",\"proxied\":true}' 'https://api.cloudflare.com/client/v4/ZONE_ID/dns_records'

github api: how to get clones?

I'm trying to get clones with (from here):
curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/{myname}/{myrep}/traffic/clones
However, I get this error:
"message": "Must have push access to repository"
I even tried:
curl -H "Authorization: token {mytoken}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/{myname}/{myrep}/traffic/clones
but I get the same error...
I used the old API version and it was easy and quick, and I cannot find a working solution... what am I missing?
(I would like to use curl since I use this command in a sh file)
curl \
-H "Authorization: token bade46eb8b548dcb47c4a3263492faa7fb857d83" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/{user}/{repository name}/traffic/clones
This command works with the new API
(the token is fake, but useful for people to have a general idea of how it looks)

Using cURL in API where a Date Array is required

I'm trying to create a simple cURL request to grab some JSON data and dump it into a file. Tried using command-line and PowerShell but can't
figure out how to use a date array as required in the documentation (https://api.officevibe.com/docs/engagement)
The support at OfficeVibe is ridiculous, unless you know exactly what you're doing they're not very willing to help and any examples provided don't actually work (as i'm assuming they need to be part of a larger app).
Can anyone offer some advice on how i can get this working? (The Bearer ID isn't our actual ID)
Example from OfficeVibe which doesn't work in command-line or PowerShell:
c:\temp\curl.exe -k -X POST https://app.officevibe.com/api/v2/engagement -H 'Authorization: Bearer 1234' -H 'Content-Type: application/json' -d '{"dates" : ["2019-04-01"]}' -o c:\temp\engagement.json
Many thanks
The answer was as easy - all i needed to do was add a backslash before the double-quote:
c:\temp\curl.exe -k -X POST https://app.officevibe.com/api/v2/engagement -H 'Authorization: Bearer 1234' -H 'Content-Type: application/json' -d '{\"dates\" : [\"2019-04-01\"]}'

Attaching a file to a comment with Basecamp API

I'm attempting to attach a file to a comment in a message with the Basecamp API. According to the documentation, I first upload the file as so:
curl -H 'Accept: application/xml' -H 'Content-Type: application/octet-stream' -u 123456789:X -X POST -d #/my/path/test.txt https://myurl.com/upload
This returns an id, so I know the file was uploaded. I then try to attach this file to a comment in a message:
curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' -u 123456789:X -X POST -d '<comment><body>This is a test</body><attachments><name>blah</name><file><file>$id</file><content-type>application/text</content-type><original-filename>test.txt</original-filename></file></attachments></comment>' https://myurl/posts/987654321/comments.xml
The comment is uploaded however the attachment is not. Does anyone know why the attachment would not be uploaded?
Thanks
I'm not sure if it's your only problem, but the value of $id isn't interpolated when you use single quotes, and so you're passing the string '$id' instead of the value of $id.
Either use '...<file>'$id'</file>...' or "...<file>$id</file>..."