# Error: Invalid api key or secret

**URL:** <https://devforum.zoom.us/t/error-invalid-api-key-or-secret/27843>\
**Category:** API and Webhooks\
**Created:** [August 22, 2020, 4:48am UTC](https://devforum.zoom.us/t/error-invalid-api-key-or-secret/27843 "2020-08-22T04:48:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ansh](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ansh/32/13779_2.png) [@Ansh](https://devforum.zoom.us/u/Ansh)\
**Post date:** [August 22, 2020, 4:48am UTC](https://devforum.zoom.us/t/error-invalid-api-key-or-secret/27843/1 "2020-08-22T04:48:52Z")

</div>

**Description**  
I am using `rauth`'s `OAuth2Service` to handle OAuth2 authentication with Python3, and I keep getting an error about an invalid api key or secret. I have attached the code below for your reference:

```auto
class ZoomClient():
    def __init__ (self,CLIENT_ID,CLIENT_SECRET, REDIRECT_URL):
        super(). __init__ ()
        self.REDIRECT_URL = REDIRECT_URL
        
        self.zoom_auth = OAuth2Service(
            client_id = CLIENT_ID,
            client_secret = CLIENT_SECRET,
            name = 'zoom',
            authorize_url = 'https://zoom.us/oauth/authorize',
            access_token_url = 'https://zoom.us/oauth/token',
            base_url = 'https://zoom.us'
        )

        self.access_token = self.get_access_token()        
        print('Access token sucessfully acquired.')

        self.make_request()

    def make_request(self):
        request_uri = 'https://api.zoom.us/v2/users/me'
        headers = {
            'Authorization' : 'Bearer {}'.format(self.access_token)
        }
        response = requests.get(request_uri, headers = headers)
        print(response.json())

    def get_decoder(self, payload):
        return json.loads(payload.decode('utf-8'))
    
    def get_access_token(self):
        session = self.zoom_auth.get_auth_session(data = {'code': 'foo', 'grant_type' : 'client_credentials', 'redirect_uri' : self.REDIRECT_URL}, decoder=self.get_decoder)
        return session.access_token

```

I have already tried replace grant\_type to code, but I receive a different error from rauth shown below:

```auto
Decoder failed to handle access_token with data as returned by provider. A different decoder may be needed. Provider returned: b\'{"reason":"Internal Error","error":"invalid_request"}

```

**Error**

```auto
{'code': 200, 'message': 'Invalid api key or secret.'}

```

**Which App Type (OAuth / Chatbot / JWT / Webhook)?**  
OAuth2

**Which Endpoint/s?**  
[https://zoom.us/oauth/](https://zoom.us/oauth/)  
[https://zoom.us/oauth/authorize](https://zoom.us/oauth/authorize)  
[https://api.zoom.us/v2/users/me](https://api.zoom.us/v2/users/me)

**How To Reproduce (If applicable)**  
Steps to reproduce the behavior:

1. Run Client class with Client ID and Secret

2. See error

---

<div class="post-metadata">

**Author:** ![DeveloperBot](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/developerbot/32/12632_2.png) [@DeveloperBot](https://devforum.zoom.us/u/DeveloperBot)\
**Post date:** [August 22, 2020, 4:49am UTC](https://devforum.zoom.us/t/error-invalid-api-key-or-secret/27843/2 "2020-08-22T04:49:35Z")

</div>

Hey @Ansh

Thanks for posting on the Zoom Devforum! I am still learning, but I will try my best to help answer your question. 🙂

Checkout this related thread that may have the answer you are looking for:

> [@Invalid api key or secret error](https://devforum.zoom.us/t/-/5227):
>
> I have been working on a Laravel project that provides online education to students. I wanted to use ZOOM services of video conferencing so that teacher can connect with his students through video conference. Following the API reference documentation, I have registered an app with zoom. I got API key and API secret along with an access token by following the documentation. I am sending subsequent requests to post/fetch data from zoom, but I have been getting an error message like this. Client …

If this thread did not help, please let us know by replying back here and someone from the Developer Relations team will get back to you shortly.

Thanks,  
DeveloperBot

---

<div class="post-metadata">

**Author:** ![Ansh](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ansh/32/13779_2.png) [@Ansh](https://devforum.zoom.us/u/Ansh)\
**Post date:** [August 22, 2020, 4:59am UTC](https://devforum.zoom.us/t/error-invalid-api-key-or-secret/27843/3 "2020-08-22T04:59:45Z")

</div>

Sorry, this didn’t help

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [August 25, 2020, 5:39pm UTC](https://devforum.zoom.us/t/error-invalid-api-key-or-secret/27843/4 "2020-08-25T17:39:08Z")

</div>

Hey @Ansh,

Please see my post here:

> [@Invalid api key or secret with OAuth token](https://devforum.zoom.us/t/invalid-api-key-or-secret-with-oauth-token/23473/2):
>
> Hey @venkat.sai, The grant type of client\_credentials will only work with [Zoom Chatbots](https://marketplace.zoom.us/docs/guides/chatbots/installation-and-authentication). You need to use the [OAuth grant type of authorization\_code](https://marketplace.zoom.us/docs/guides/auth/oauth#getting-access-token). Can you share a screenshot and steps to reproduce this error: “Note: if we use the grant type as Authorization code we are getting page not found.”. Thanks, Tommy

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![Ansh](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ansh/32/13779_2.png) [@Ansh](https://devforum.zoom.us/u/Ansh)\
**Post date:** [August 25, 2020, 6:14pm UTC](https://devforum.zoom.us/t/error-invalid-api-key-or-secret/27843/5 "2020-08-25T18:14:10Z")

</div>

Hi @tommy,

I think I tried this, and I received another error. I have attached the full error below:

```auto
    z = ZoomClient(' ****', '****', 'https://google.com')
  File "/Users/***/Desktop/Zoom-Attendance/src/models.py", line 20, in __init__
    self.access_token = self.get_access_token()        
  File "/Users/***/Desktop/Zoom-Attendance/src/models.py", line 38, in get_access_token
    session = self.zoom_auth.get_auth_session(data = {'code': 'foo', 'grant_type' : 'authorization_code', 'redirect_uri' : self.REDIRECT_URL}, decoder=self.get_decoder)
  File "/opt/anaconda3/lib/python3.7/site-packages/rauth/service.py", line 556, in get_auth_session
    session = self.get_session(self.get_access_token(method, **kwargs))
  File "/opt/anaconda3/lib/python3.7/site-packages/rauth/service.py", line 542, in get_access_token
    access_token, = process_token_request(r, decoder, key)
  File "/opt/anaconda3/lib/python3.7/site-packages/rauth/service.py", line 24, in process_token_request
    raise KeyError(PROCESS_TOKEN_ERROR.format(key=bad_key, raw=r.content))
KeyError: 'Decoder failed to handle access_token with data as returned by provider. A different decoder may be needed. Provider returned: b\'{"reason":"Invalid authorization code foo","error":"invalid_request"}\''

```

The change I made was to switch `grant_type` to `"authorization_code"`. I censored certain directories / client secrets using \*\*\* as they have revealing names/info.

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [August 27, 2020, 9:48pm UTC](https://devforum.zoom.us/t/error-invalid-api-key-or-secret/27843/6 "2020-08-27T21:48:55Z")

</div>

Hey @Ansh,

Make sure you are only using the auth code in the redirect url once.

It is only valid once, then you will need to [refresh the access token using the refresh flow](https://marketplace.zoom.us/docs/guides/auth/oauth#refreshing).

Thanks,  
Tommy

---

<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:** [September 27, 2020, 7:48am UTC](https://devforum.zoom.us/t/error-invalid-api-key-or-secret/27843/7 "2020-09-27T07:48:55Z")

</div>

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