I am trying to implement the second example given in the Spark Examples “Connecting LED through internet”. For some reason, my curl command always fails in the Mac terminal. I have reset the token and added the new token every time and also made sure the core has the right id. But still it says the following.
{
“code”: 400,
“error”: “invalid_grant”,
“error_description”: “The access token provided has expired.”
}curl: (6) Could not resolve host:
Can you paste the command you are running? The error at the end looks like your command isn’t formatted correctly. Make sure you put the URL in quotes.
curl “http://example.com?foo=bar”
Good call @amanfredi , that has burned me too. Additionally, I’d recommend using single quotes instead of double and also quoting the other parameters as well like this:
curl 'https://api.spark.io/v1/devices/0123456789abcdef01234567/led' -d 'access_token=1234123412341234123412341234123412341234' -d 'params=l1,HIGH'
Single quotes are more restrictive than double quotes in terms of what gets interpolated in bash (the underlying program of the Mac Terminal)