# Unauthorized error in CloudQuery deployment with API key usage guidance needed

**URL:** <https://community.cloudquery.io/t/unauthorized-error-in-cloudquery-deployment-with-api-key-usage-guidance-needed/302>\
**Category:** CloudQuery Plugins\
**Created:** [March 14, 2024, 11:39am UTC](https://community.cloudquery.io/t/unauthorized-error-in-cloudquery-deployment-with-api-key-usage-guidance-needed/302 "2024-03-14T11:39:16Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![live-bonefish](https://avatars.discourse-cdn.com/v4/letter/l/a9a28c/32.png) [@live-bonefish](https://community.cloudquery.io/u/live-bonefish)\
**Post date:** [March 14, 2024, 11:39am UTC](https://community.cloudquery.io/t/unauthorized-error-in-cloudquery-deployment-with-api-key-usage-guidance-needed/302/1 "2024-03-14T11:39:16Z")

</div>

Hi guys, I am deploying CloudQuery in my Kubernetes cluster and I am getting an unauthorized error:

```json
{"level":"warn","module":"cli","time":"2024-03-14T11:12:59Z","message":"when using the CloudQuery registry, it's recommended to log in via `cloudquery login`. Logging in allows for better rate limits and downloading of premium plugins"}

```

I want to use `CLOUDQUERY_API_KEY=<your-api-key>`, but I am not sure where I should use the API key. I cannot export it on the server directly, and I want to use it as a secret. However, I have no idea how to do this in the config or cronjob. Can someone please share an example as well?

I have created the secret and used it in the cronjob, but it didn’t work.

---

<div class="post-metadata">

**Author:** ![herman](https://sea1.discourse-cdn.com/flex001/user_avatar/community.cloudquery.io/herman/32/27_2.png) [@herman](https://community.cloudquery.io/u/herman)\
**Post date:** [March 14, 2024, 11:48am UTC](https://community.cloudquery.io/t/unauthorized-error-in-cloudquery-deployment-with-api-key-usage-guidance-needed/302/2 "2024-03-14T11:48:30Z")

</div>

Hi @live-bonefish,

If you set `CLOUDQUERY_API_KEY` as an environment variable, it should work.

Can you share your Kubernetes configs maybe, so we can have a look at what the problem could be?

---

<div class="post-metadata">

**Author:** ![live-bonefish](https://avatars.discourse-cdn.com/v4/letter/l/a9a28c/32.png) [@live-bonefish](https://community.cloudquery.io/u/live-bonefish)\
**Post date:** [March 14, 2024, 11:49am UTC](https://community.cloudquery.io/t/unauthorized-error-in-cloudquery-deployment-with-api-key-usage-guidance-needed/302/3 "2024-03-14T11:49:12Z")

</div>

```auto
apiVersion: v1
kind: ConfigMap
metadata:
  name: cloudquery-apikey
  namespace: cloudquery
data:
  CLOUDQUERY_API_KEY: xxxxxxxxxx

```

---

<div class="post-metadata">

**Author:** ![herman](https://sea1.discourse-cdn.com/flex001/user_avatar/community.cloudquery.io/herman/32/27_2.png) [@herman](https://community.cloudquery.io/u/herman)\
**Post date:** [March 14, 2024, 11:49am UTC](https://community.cloudquery.io/t/unauthorized-error-in-cloudquery-deployment-with-api-key-usage-guidance-needed/302/4 "2024-03-14T11:49:47Z")

</div>

Could you share the cronjob config as well?

Also, I don’t know if you’ve seen it, but there is a tutorial on deploying to Kubernetes [here](https://docs.cloudquery.io/docs/deployment/kubernetes). It doesn’t show `CLOUDQUERY_API_KEY` specifically, but it does use other secrets.

---

<div class="post-metadata">

**Author:** ![live-bonefish](https://avatars.discourse-cdn.com/v4/letter/l/a9a28c/32.png) [@live-bonefish](https://community.cloudquery.io/u/live-bonefish)\
**Post date:** [March 14, 2024, 11:55am UTC](https://community.cloudquery.io/t/unauthorized-error-in-cloudquery-deployment-with-api-key-usage-guidance-needed/302/5 "2024-03-14T11:55:44Z")

</div>

So if you see, I am doing something like this:

```auto
envFrom:
  - secretRef:
      name: cloudquery-secret-test

```

---

<div class="post-metadata">

**Author:** ![herman](https://sea1.discourse-cdn.com/flex001/user_avatar/community.cloudquery.io/herman/32/27_2.png) [@herman](https://community.cloudquery.io/u/herman)\
**Post date:** [March 14, 2024, 11:56am UTC](https://community.cloudquery.io/t/unauthorized-error-in-cloudquery-deployment-with-api-key-usage-guidance-needed/302/6 "2024-03-14T11:56:59Z")

</div>

Ok, thanks. Did you create the secret like this?

```auto
kubectl create secret generic cloudquery-secret-test \
--from-literal=CLOUDQUERY_API_KEY=<your_key>

```

---

<div class="post-metadata">

**Author:** ![herman](https://sea1.discourse-cdn.com/flex001/user_avatar/community.cloudquery.io/herman/32/27_2.png) [@herman](https://community.cloudquery.io/u/herman)\
**Post date:** [March 14, 2024, 11:57am UTC](https://community.cloudquery.io/t/unauthorized-error-in-cloudquery-deployment-with-api-key-usage-guidance-needed/302/7 "2024-03-14T11:57:25Z")

</div>

I don’t have a specific example for `CLOUDQUERY_API_KEY`, but it’s an environment variable like any other.

---

<div class="post-metadata">

**Author:** ![live-bonefish](https://avatars.discourse-cdn.com/v4/letter/l/a9a28c/32.png) [@live-bonefish](https://community.cloudquery.io/u/live-bonefish)\
**Post date:** [March 14, 2024, 11:58am UTC](https://community.cloudquery.io/t/unauthorized-error-in-cloudquery-deployment-with-api-key-usage-guidance-needed/302/8 "2024-03-14T11:58:26Z")

</div>

i am not sure what I am doing wrong here

---

<div class="post-metadata">

**Author:** ![herman](https://sea1.discourse-cdn.com/flex001/user_avatar/community.cloudquery.io/herman/32/27_2.png) [@herman](https://community.cloudquery.io/u/herman)\
**Post date:** [March 14, 2024, 11:58am UTC](https://community.cloudquery.io/t/unauthorized-error-in-cloudquery-deployment-with-api-key-usage-guidance-needed/302/9 "2024-03-14T11:58:53Z")

</div>

Can you double-check the command you used to create the secret and make sure there are no typos or anything?

---

<div class="post-metadata">

**Author:** ![herman](https://sea1.discourse-cdn.com/flex001/user_avatar/community.cloudquery.io/herman/32/27_2.png) [@herman](https://community.cloudquery.io/u/herman)\
**Post date:** [March 14, 2024, 11:59am UTC](https://community.cloudquery.io/t/unauthorized-error-in-cloudquery-deployment-with-api-key-usage-guidance-needed/302/10 "2024-03-14T11:59:49Z")

</div>

You can also do

```auto
kubectl describe secret cloudquery-secret-test

```

---

<div class="post-metadata">

**Author:** ![live-bonefish](https://avatars.discourse-cdn.com/v4/letter/l/a9a28c/32.png) [@live-bonefish](https://community.cloudquery.io/u/live-bonefish)\
**Post date:** [March 14, 2024, 12:11pm UTC](https://community.cloudquery.io/t/unauthorized-error-in-cloudquery-deployment-with-api-key-usage-guidance-needed/302/11 "2024-03-14T12:11:33Z")

</div>

Ahh man, it was the typo in the token. Thank you, I appreciate the help @herman!
