# Ruby auth0 gem - how to configure with Client Key? I keep getting "unauthorized" / "invalid token"

**URL:** <https://community.auth0.com/t/ruby-auth0-gem-how-to-configure-with-client-key-i-keep-getting-unauthorized-invalid-token/85750>\
**Category:** Get Help\
**Tags:** ruby, auth0\
**Created:** [June 22, 2022, 7:53pm UTC](https://community.auth0.com/t/ruby-auth0-gem-how-to-configure-with-client-key-i-keep-getting-unauthorized-invalid-token/85750 "2022-06-22T19:53:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbirchmeier](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gbirchmeier/32/37427_2.png) [@gbirchmeier](https://community.auth0.com/u/gbirchmeier)\
**Post date:** [June 22, 2022, 7:53pm UTC](https://community.auth0.com/t/ruby-auth0-gem-how-to-configure-with-client-key-i-keep-getting-unauthorized-invalid-token/85750/1 "2022-06-22T19:53:26Z")

</div>

Using Ruby `auth0` gem 5.8.0

I’ve written an `auth0_client` function based on the one in the [auth0 gem’s homepage](https://github.com/auth0/ruby-auth0) and plugged in my app’s credentials, but I keep getting:

```auto
{"statusCode":401,"error":"Unauthorized","message":"Invalid token","attributes":{"error":"Invalid token"}}

```

This is my function:

```ruby
  def auth0_client
    @auth0_client ||= Auth0Client.new(
      client_id: xxx, # value from my app's "Basic Information" page
      client_secret: xxx, # value from my app's "Basic Information" page
      domain: xxx # value from my app's "Basic Information" page
      api_version: 2,
      timeout: 15

      # I don't need this, do I?
      #token: ENV['AUTH0_RUBY_API_TOKEN'],
    )
  end

```

What can possibly be wrong with the credentials that I passed in? Am I missing something? What token is invalid?

---

<div class="post-metadata">

**Author:** ![gbirchmeier](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gbirchmeier/32/37427_2.png) [@gbirchmeier](https://community.auth0.com/u/gbirchmeier)\
**Post date:** [June 23, 2022, 1:56pm UTC](https://community.auth0.com/t/ruby-auth0-gem-how-to-configure-with-client-key-i-keep-getting-unauthorized-invalid-token/85750/2 "2022-06-23T13:56:29Z")

</div>

We figured out that we missed: we didn’t have permissions set for the Management API.

The interface is kind of easy to miss. On the application’s API tab, you need to click the little drop-down arrow on the right to open up the permissions pane:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/c/b/cbd05d2385bb683505f1c7855e180f9689c2d320.png)

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [June 23, 2022, 3:43pm UTC](https://community.auth0.com/t/ruby-auth0-gem-how-to-configure-with-client-key-i-keep-getting-unauthorized-invalid-token/85750/3 "2022-06-23T15:43:13Z")

</div>

Glad to know you have found the solution! Thank you for sharing it with our community! 👏 👍

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [November 4, 2022, 2:46pm UTC](https://community.auth0.com/t/ruby-auth0-gem-how-to-configure-with-client-key-i-keep-getting-unauthorized-invalid-token/85750/4 "2022-11-04T14:46:37Z")

</div>


