# Getting a valid token with 200status but when trying to create a meeting im getting invalid access token

**URL:** <https://devforum.zoom.us/t/getting-a-valid-token-with-200status-but-when-trying-to-create-a-meeting-im-getting-invalid-access-token/89908>\
**Category:** Authentication\
**Created:** [June 9, 2023, 2:41pm UTC](https://devforum.zoom.us/t/getting-a-valid-token-with-200status-but-when-trying-to-create-a-meeting-im-getting-invalid-access-token/89908 "2023-06-09T14:41:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![haithem.nasri.pro](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/haithem.nasri.pro/32/49271_2.png) [@haithem.nasri.pro](https://devforum.zoom.us/u/haithem.nasri.pro)\
**Post date:** [June 9, 2023, 2:41pm UTC](https://devforum.zoom.us/t/getting-a-valid-token-with-200status-but-when-trying-to-create-a-meeting-im-getting-invalid-access-token/89908/1 "2023-06-09T14:41:16Z")

</div>

### Format Your New Topic as Follows:

**API Endpoint(s) and/or Zoom API Event(s)**  
[https://api.zoom.us/v2/users/me/meetings](https://api.zoom.us/v2/users/me/meetings)

**Description**  
I configured a server-to-server oauth app awith these scopes “meeting:read:admin meeting:write:admin etc” and i am trying to create a meeting.

**Error?**  
each time i try to execute a service in my spingboot project to create a meeting through this POST endpoint  
“[https://api.zoom.us/v2/users/me/meetings](https://api.zoom.us/v2/users/me/meetings)”, i get this error :  
401 Unauthorized: “{“code”:124,”message”:”Invalid access token.”}"  
I am calling the service only once, not using multiple instances of my project or multiple thread .  
**Debugging**  
When debugging, i see that i am retrieving a token, and when i try to use that token and use it in postman instead of continuing the service pocess in the debug mode, i get invalid access token too.  
But if i generate the access token using Postman, the token allows me to create the meeting ( even tho im using same credentials)

So the issue is probably in this code ?

```auto
  private void generateAccessToken() {

    //the uri for generating an Access token
    URI uri = UriComponentsBuilder
        .fromUriString(OAUTH_API_URL)
        .queryParam("grant_type", "client_credentials")
        .queryParam("account_id", ACCOUNT_ID)
        .build()
        .toUri();

    //Setting basic auth credentials & Media type in header
    HttpHeaders headers = new HttpHeaders();
    headers.setBasicAuth(CLIENT_ID, CLIENT_SECRET);
    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

    HttpEntity<?> requestEntity = new HttpEntity<>(headers);

    //Calling the endpoint
    ResponseEntity<AccessTokenResponse> responseEntity = restTemplate.exchange(
        uri,
        HttpMethod.POST,
        requestEntity,
        AccessTokenResponse.class);
    
    
    if (responseEntity.getStatusCode() == HttpStatus.OK) {
      AccessTokenResponse accessTokenResponse = responseEntity.getBody();
      if (accessTokenResponse != null) {
        this.accessToken = accessTokenResponse.getAccessToken();
        this.accessTokenExpiry = LocalDateTime
            .now()
            .plusSeconds(accessTokenResponse.getExpiresIn());
      }
    }
  }

  @Getter
  private static class AccessTokenResponse {

    @JsonProperty("access_token")
    private String accessToken;

    @JsonProperty("expires_in")
    private int expiresIn;
  }

```

---

<div class="post-metadata">

**Author:** ![jharris1](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@jharris1](https://devforum.zoom.us/u/jharris1)\
**Post date:** [June 9, 2023, 3:17pm UTC](https://devforum.zoom.us/t/getting-a-valid-token-with-200status-but-when-trying-to-create-a-meeting-im-getting-invalid-access-token/89908/2 "2023-06-09T15:17:38Z")

</div>

Possibly related to this? [Jwt authentication starts return 401 at 2023-06-09 13:00 UTC+9 - API and Webhooks / Authentication - Zoom Developer Forum](https://devforum.zoom.us/t/jwt-authentication-starts-return-401-at-2023-06-09-13-00-utc-9/89884/3)

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [June 9, 2023, 5:20pm UTC](https://devforum.zoom.us/t/getting-a-valid-token-with-200status-but-when-trying-to-create-a-meeting-im-getting-invalid-access-token/89908/3 "2023-06-09T17:20:35Z")

</div>

Hi @haithem.nasri.pro  
Thanks for reaching out to us!  
It looks like you are passing the wrong grant\_type in your request to generate the access\_token.  
If you are using a Server to Server Oauth app, you should be passing grant\_type=account\_credentials in your request instead of client\_credentials.

> **[Internal apps (Server-to-server)](https://developers.zoom.us/docs/internal-apps/#terminal-command-line-curl-method)**
>
> The Zoom Developer Platform is an open platform that allows third-party developers to build applications and integrations upon Zoom’s video-first unified communications platform.

could you please double check that form me ant let me know if that helped!  
cheers,  
Elisa

---

<div class="post-metadata">

**Author:** ![haithem.nasri.pro](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/haithem.nasri.pro/32/49271_2.png) [@haithem.nasri.pro](https://devforum.zoom.us/u/haithem.nasri.pro)\
**Post date:** [June 12, 2023, 8:27am UTC](https://devforum.zoom.us/t/getting-a-valid-token-with-200status-but-when-trying-to-create-a-meeting-im-getting-invalid-access-token/89908/4 "2023-06-12T08:27:55Z")

</div>

hi  
Thanks for your reply, and yes you are right i have just checked that today morning!  
Seems like this is your typical friday afternoon malfunction haha

Thanks again

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [June 12, 2023, 3:06pm UTC](https://devforum.zoom.us/t/getting-a-valid-token-with-200status-but-when-trying-to-create-a-meeting-im-getting-invalid-access-token/89908/5 "2023-06-12T15:06:29Z")

</div>

Happy to hear its working now! @haithem.nasri.pro  
Let us know if there is anything else we could to to support you  
Cheers,  
Elisa

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [June 12, 2023, 3:08pm UTC](https://devforum.zoom.us/t/getting-a-valid-token-with-200status-but-when-trying-to-create-a-meeting-im-getting-invalid-access-token/89908/6 "2023-06-12T15:08:23Z")

</div>

Closed on June 12, 2023, 3:08pm UTC


