# Account ID doesn't exist in decoded Chatbot access token

**URL:** <https://devforum.zoom.us/t/account-id-doesnt-exist-in-decoded-chatbot-access-token/80363>\
**Category:** API and Webhooks\
**Tags:** api\
**Created:** [December 15, 2022, 5:55pm UTC](https://devforum.zoom.us/t/account-id-doesnt-exist-in-decoded-chatbot-access-token/80363 "2022-12-15T17:55:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandra](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/alexandra/32/39489_2.png) [@Alexandra](https://devforum.zoom.us/u/Alexandra)\
**Post date:** [December 15, 2022, 5:55pm UTC](https://devforum.zoom.us/t/account-id-doesnt-exist-in-decoded-chatbot-access-token/80363/1 "2022-12-15T17:55:38Z")

</div>

Hello! I’m creating a Chatbot and trying to get the `account_id` so that I have the info that I need to send messages, but am having a hard time with finding where I can get it – and I specifically need the information when the app is installed, and not via the payload found in webhooks when the bot is interacted with.

I have the auth process set up and am receiving an access token for the chatbot and am able to post messages with it successfully when I hardcode my own account ID, so I know that it’s set up properly. I saw [this forum post](https://devforum.zoom.us/t/deauthorization-endpoint-user-identification/33047/6) which suggests decoding the access token and getting the `aid` value. I tried that, but the data for my token looks like this (with all values other than `ver, `aud`, and `type` redacted):

```auto
{
'aud': 'https://oauth.zoom.us',
'uid': 'abc', 
'ver': 7, 
'auid': 'abc',
'nbf': 123,
'iss': 'abc',
'gno': 0, 
'exp': 123, 
'type': 2,
'iat': 123, 
'jti': 'abc'
}

```

There’s no `aid` key in there, and none of the actual values correspond to my account ID. I did notice that when I switched the OAuth process for the chatbot to use the `authorization_code` grant type instead of `client_credentials`, the account ID key was present – but then that access token doesn’t work with the chatbot API and I can’t post any messages. I also can’t use the access token to get the current user’s info, where that account ID would also be.

It feels like I must be missing something, the account ID is really important information so I can’t imagine that there would be no way of getting it. How can I access this info?

---

<div class="post-metadata">

**Author:** ![ojus.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ojus.zoom/32/734_2.png) [@ojus.zoom](https://devforum.zoom.us/u/ojus.zoom)\
**Post date:** [December 15, 2022, 10:33pm UTC](https://devforum.zoom.us/t/account-id-doesnt-exist-in-decoded-chatbot-access-token/80363/2 "2022-12-15T22:33:19Z")

</div>

Hi Aleksandra,

At the moment, we do not have a direct way of providing app developers with the accountID of the user who installs their app.

The easiest way right now to get the account ID is:  
1] Select the user read scope for your app  
2] When the user installs the app, zoom will redirect them to your redirect URL, you need to capture their userID (as you are currently doing)  
3] Call the get user API to get the account ID.

Again, I wish there was an easier way to do this, but there isnt at the moment. That said, I will be creating a feature request to add a “app\_authorized” event just like the deauthorized one. Follow our [changelog](https://marketplace.zoom.us/docs/guides/stay-up-to-date/changelog/) to stay updated with the latest updates.

---

<div class="post-metadata">

**Author:** ![Alexandra](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/alexandra/32/39489_2.png) [@Alexandra](https://devforum.zoom.us/u/Alexandra)\
**Post date:** [December 16, 2022, 3:17am UTC](https://devforum.zoom.us/t/account-id-doesnt-exist-in-decoded-chatbot-access-token/80363/3 "2022-12-16T03:17:55Z")

</div>

Hi Ojus,

Thanks for the reply, but unfortunately that solution isn’t working either. Here’s a screenshot of requests that I’m making to post a chat message successfully, and then one to get my user information which fails with a 400, and shows that I have both the `user:read:admin` and `imchat:bot` scopes.

 ![Screen Shot 2022-12-15 at 10.02.07 PM](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/4/6/462346129d03c2b425dab45b20ade24217837155.png)

The call to the users endpoint only works when I request the access token using `authorization_code` as the grant type, but that token then doesn’t work with the chatbot endpoint (only the ones generated using `client_credentials` as the grant type work with that).

So it sounds like I would need to have both this chatbot app _and_ a separate app where the same user needs to authorize both, and then match the user ID value from the decoded access token in the chatbot app against the result from the call to `users/me`, _just_ to get the account ID.

It still feels like there must be something missing here because I see apps in the marketplace that are written by Zoom and request both the `im:chatbot` and `user:read:admin` scopes, so there must be a way of authorizing for both of those with the same app and same grant type?

---

<div class="post-metadata">

**Author:** ![Alexandra](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/alexandra/32/39489_2.png) [@Alexandra](https://devforum.zoom.us/u/Alexandra)\
**Post date:** [January 9, 2023, 2:20am UTC](https://devforum.zoom.us/t/account-id-doesnt-exist-in-decoded-chatbot-access-token/80363/4 "2023-01-09T02:20:05Z")

</div>

To update for anyone else who might run into this same issue, I figured out what was going wrong.

TLDR once the admin has authorized the app, you need to do two requests: one to get the OAuth token (using the `authorization_code` grant type) and another to get the Chatbot token (using the `client_credentials` grant type) and store those separately, and use the appropriate one for each type of API call.

More info here: [https://marketplace.zoom.us/docs/guides/auth/oauth/#oauth-with-chatbots](https://marketplace.zoom.us/docs/guides/auth/oauth/#oauth-with-chatbots)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [January 12, 2024, 5:56pm UTC](https://devforum.zoom.us/t/account-id-doesnt-exist-in-decoded-chatbot-access-token/80363/5 "2024-01-12T17:56:25Z")

</div>

Closed on January 12, 2024, 5:56pm UTC

This topic was automatically closed 368 days after the last reply. New replies are no longer allowed.
