API token vs. access token

My access token doesn’t work when I run “ipinfo init”. I cannot see any other tokens in my account. Is the API token the same as the access token? If yes, why isn’t it working? If no, how can I get it? (Platform: macOS Sequoia 15.2, Apple silicon, homebrew)

Thanks in advance.

Each user has a “token” which we typically refer to just as an “[api] token” but in some places we mistakenly refer to it as an “access token” (like Account > Profile). We’re currently working on a new dashboard that will correct this mistake. For now, you can read “access token” as “api token”. Sorry for the confusion!

If your token doesn’t work when running ipinfo init can you share the error message you receive? You can also validate whether your token is correct in your browser using the /me endpoint, e.g:

https://ipinfo.io/me?token=example

That’ll show your token’s details and limits:

{
  "token": "...",
  "requests": {
    "day": 0,
    "month": 1,
    "limit": 2147483647,
    "remaining": 2147483646
  },
  "features": {
    "core": {
      "daily": 2147483647,
      "monthly": 2147483647
    },
    "hostio": {
      "daily": 2147483647,
      "monthly": 1000,
      "result_limit": 5
    }
  }
}
1 Like

Web browser and curl work just fine. My request count increases when I use them, too. The error message is “err: could not confirm if token is valid: invalid token”.

@egokcen that likely means there may have been an extra character in your token when setting up the CLI. Can you try running this command – replacing example with your token:

ipinfo config token=example

And then try using the CLI again, e.g:

ipinfo 1.1.1.1
2 Likes

That worked. I was pasting the token directly from the web page. This time, I pasted it into a text editor and copied it from there. I think it would have worked if I had done the same with “ipinfo init”, too.

Thanks a lot! :slight_smile:

2 Likes

I’m glad it’s working!

Did you copy it from the Account > Token page or was it a page in the documentation? We can push a fix so that when highlighting the value it trims off any spaces.

I’ll also make a note that we should provide more information in the CLI when a token is rejected, e.g: if the value is not equal to 14 characters we can provide a helpful error message.

1 Like

Edit: I copied the token from the Account ––> Token page.

There were no visible leading and trailing spaces in the API key when I pasted them into the terminal, they were all 14-characters long. I did some tests for you by logging out trying to log back in, and I can assure you that the very same token copied from the same web page works with “ipinfo config token=”, but it doesn’t work when you enter it interactively with “ipinfo init”, even when you paste the token into a text editor and copying it from there to strip any invisible character(s) thay may have been copied from the web page. I did the tests on two different terminals, one of them being the stock macOS Terminal app.

You should really look into this.

@egokcen thank you for further debugging!

I can’t reproduce this but given you’ve tested it across multiple terminals, it certainly sounds like a bug. The CLI stores the token (provided through ipinfo init) in a configuration file. Can you check that config file and check if there’s any obvious issue with the token field (empty or includes extra characters)?

cat ~/Library/Application\ Support/ipinfo/config.json

The file should look like this:

{"cache_enabled":true,"token":"example","open_browser":true}

No problem at all… I’m a VERY happy “customer”, and I’m glad I can help you in some way. :slight_smile:

VERY weird issue indeed… I thought it might be related to the browser and extensions I’m using (Firefox), but I get the same error with plain stock Chrome without any extensions, too. Token remains empty after I log out and “ipinfo init” fails and is populated after “ipinfo config token=” runs, as expected.

Anyway, my problem has been solved. Thanks for the prompt replies.

1 Like