API Key Not Working

I’ve been unable to authenticate with the API. I got my key from my account settings page. When I use the command below (not using my real key in this example):

curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer 123abc2d-89ef-4567-890a-1dd2efa345bc" https://api.rach.io/1/public/person/info

I receive the error:

{"errors":[{"message":"The client is not authorized."}]}

Am I doing this incorrectly or missing something?

I have no idea what could be wrong. I took the exact line you posted:

curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer 123abc2d-89ef-4567-890a-1dd2efa345bc" https://api.rach.io/1/public/person/info

and replaced the key string beginning 123a and ending 45bc with my key and it provided the ID as expected.

I obtained the key by visiting app.rach.io, going to Account Settings, clicking GET API KEY, then clicking the Copy symbol. I then pasted it into the command you provided.

If you are sure that you have exactly 36 characters for your key, try

curl --trace foo.txt -H "Content-Type: application/json" -H "Authorization: Bearer 123abc2d-89ef-4567-890a-1dd2efa345bc" https://api.rach.io/1/public/person/info

(with the correct key)
then look at the file foo.txt for problems.

1 Like

Hello Stewart - thank you for the suggestion. I ran the curl trace with my key, which I obtained as you outlined and validated it was 36 characters in length. I received the same error message again.

The resulting trace file is here (not my real API key again, although I did use the real one in on my command line).

Could the web UI simply be providing me an incorrect API key?

I believe that’s likely. My older curl was using HTTP 1.1 and I thought that there may be a problem with HTTP 2. But after installing latest curl 7.68.0, access via HTTP 2 was still successful.

Try running your curl example with a web app token instead of what the web UI is giving you.
Edit the perl script below with your email and password then run it. If there are no errors it will print an access token. Try that with curl.


use LWP::UserAgent;
use JSON;

$user = 'me@mydomain.com';      # replace with the email address for your Rachio account
$pass = 'supersecret';          # replace with your Rachio account password

sub doreq {                     # print error and exit if request unsuccessful
    my ($name, $resp) = @_;
    return $resp->content if $resp->is_success;
    my $err = $resp->content;
    print "Request for $name failed: $err\n";

$ua = LWP::UserAgent->new();

# get config data
$cfg = decode_json(doreq('config', $ua->get('https://app.rach.io/env.json')));

# log in and get access token
$token = decode_json(doreq('login', $ua->post("$cfg->{AUTH_SERVICE_URL}/token",
                                 [ 'grant_type' => 'password', 'username' => $user, 'password' => $pass,
                                   'client_id' => $cfg->{CLIENT_ID}, 'client_secret' => $cfg->{CLIENT_SECRET} ])))->{access_token};
print $token;

If that works, contact Rachio about the bad API key. If the perl works but the key it prints fails with curl, most likely curl is malfunctioning on your system, but I have no idea how or why. If the perl script bombs out, something is likely strange with your account.

1 Like

Thanks again Stewart, the curl command does indeed work with the web app token retrieved via your perl script. Using this token, I receive the following (obfuscated my real ID):


I’ll contact Rachio and see what they say regarding my API key.

This should be fixed. I had the engineering team review and it looks like some of these tokens had an expiration date for this year. The team moved the expiration date much further into the future.


1 Like

Thank you - working now! Gotta love the community and founder support :+1: