# Personal API Token could not be used

**URL:** <https://discuss.circleci.com/t/personal-api-token-could-not-be-used/45592>\
**Category:** Deployments\
**Created:** [September 28, 2022, 12:21am UTC](https://discuss.circleci.com/t/personal-api-token-could-not-be-used/45592 "2022-09-28T00:21:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SalifT](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/salift/32/31221_2.png) [@SalifT](https://discuss.circleci.com/u/SalifT)\
**Post date:** [September 28, 2022, 12:21am UTC](https://discuss.circleci.com/t/personal-api-token-could-not-be-used/45592/1 "2022-09-28T00:21:48Z")

</div>

I created a Personal API token from [https://circleci.com/account/api](https://circleci.com/account/api)  
I’m running in terminal a build tools that requires cirlceCI’s personal API token to create a project. It prompts me to enter the Circleci personal API token. When I enter the token, I keep getting the following message:  
**[notice]** Call CircleCI API: [https://circleci.com/api/v1.1/me](https://circleci.com/api/v1.1/me) Your provided authentication token could not be used to authenticate with the CircleCI service. Please re-enter your credential.

This is not the first time I run this to create a Github repo and deploy the project on Pantheon . It had always run before.

---

<div class="post-metadata">

**Author:** ![lukerhd](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/lukerhd/32/31232_2.png) [@lukerhd](https://discuss.circleci.com/u/lukerhd)\
**Post date:** [September 29, 2022, 1:58am UTC](https://discuss.circleci.com/t/personal-api-token-could-not-be-used/45592/2 "2022-09-29T01:58:15Z")

</div>

I too am having this same issue, seems to be throwing a 400 when called via the terminus-build-tools-plugin. I was able to work around this by updating the following function: [terminus-build-tools-plugin/CircleCIProvider.php at 2.x · pantheon-systems/terminus-build-tools-plugin · GitHub](https://github.com/pantheon-systems/terminus-build-tools-plugin/blob/2.x/src/ServiceProviders/CIProviders/CircleCI/CircleCIProvider.php#L176)

Not the prettiest code, but got the job done for me

```auto
  protected function circleCIAPI($data, $url, $method = 'POST')
  {
    $this->logger->notice('Call CircleCI API: {uri}', ['uri' => $url]);

    // Do some other logic for GET requests vs other requests...
    // The API request during build:site:create fails w/o this...
    if ($method == 'GET') {
      $headers = [
        'Content-Type' => 'application/json',
        'User-Agent' => ProviderEnvironment::USER_AGENT,
        'Accept' => 'application/json',
        'Circle-token' => $this->circle_token,
        'Host' => 'circleci.com',
      ];
    } else {
      $headers = [
        'Content-Type' => 'application/json',
        'User-Agent' => ProviderEnvironment::USER_AGENT,
        'Accept' => 'application/json',
      ];
    }

    $client = new \GuzzleHttp\Client();

    // Do some other logic for GET requests vs other requests...
    // The API request during build:site:create fails w/o this...
    if ($method == 'GET') {
      $res = $client->request($method, $url, [
        'headers' => $headers
      ]);
    } else {
      $res = $client->request($method, $url, [
        'headers' => $headers,
        'auth' => [$this->circle_token, ''],
        'json' => $data,
      ]);
    }

    return $res->getStatusCode();
  }

```

Hope this helps you! Note: I think the 3.x version of the plugin has the same function, just located in a slightly different place. Cheers!

---

<div class="post-metadata">

**Author:** ![SalifT](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/salift/32/31221_2.png) [@SalifT](https://discuss.circleci.com/u/SalifT)\
**Post date:** [October 3, 2022, 5:34pm UTC](https://discuss.circleci.com/t/personal-api-token-could-not-be-used/45592/3 "2022-10-03T17:34:07Z")

</div>

Thank you lukerhd for your guide to terminus!  
I reinstalled terminus to version 3.0.7 and reinstalled terminus-build-tools-plugin. Everything worked.
