# {“code”:”124”,”message”:”Invalid access token”} error for User creation API using Asp.net api call?

**URL:** <https://devforum.zoom.us/t/code-124-message-invalid-access-token-error-for-user-creation-api-using-asp-net-api-call/80315>\
**Category:** API and Webhooks\
**Tags:** api\
**Created:** [December 14, 2022, 6:35pm UTC](https://devforum.zoom.us/t/code-124-message-invalid-access-token-error-for-user-creation-api-using-asp-net-api-call/80315 "2022-12-14T18:35:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nirmaltiwari139](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/nirmaltiwari139/32/43815_2.png) [@nirmaltiwari139](https://devforum.zoom.us/u/nirmaltiwari139)\
**Post date:** [December 14, 2022, 6:35pm UTC](https://devforum.zoom.us/t/code-124-message-invalid-access-token-error-for-user-creation-api-using-asp-net-api-call/80315/1 "2022-12-14T18:35:22Z")

</div>

public static string sGenerateJwtToken()  
{

```
        // Token will be good for 20 minutes
        DateTime Expiry = DateTime.UtcNow.AddMinutes(20);

        string ApiKey = sApiKey;
        string ApiSecret = sApiSecret;

        string SdkKey = sSdkKey;
        string SdkSecret = sSdkSecret;

        int ts = (int)(Expiry - new DateTime(1970, 1, 1)).TotalSeconds;

        // Create Security key using private key above:
        //var securityKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(Encoding.UTF8.GetBytes(ApiSecret));
        var securityKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(Encoding.UTF8.GetBytes(SdkSecret));

        // length should be >256b
        var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);

        //Finally create a Token
        var header = new JwtHeader(credentials);

        //Zoom Required Payload
        var payload = new JwtPayload
        {  
            {"appKey",SdkKey},
           { "sdkKey", SdkKey },
           { "exp", ts },
        };

        var secToken = new JwtSecurityToken(header, payload);
        var handler = new JwtSecurityTokenHandler();

        // Token to String so you can use it in your client
        var tokenString = handler.WriteToken(secToken);

        return tokenString;

    }

```

---

<div class="post-metadata">

**Author:** ![rarev](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/rarev/32/38939_2.png) [@rarev](https://devforum.zoom.us/u/rarev)\
**Post date:** [December 14, 2022, 6:53pm UTC](https://devforum.zoom.us/t/code-124-message-invalid-access-token-error-for-user-creation-api-using-asp-net-api-call/80315/2 "2022-12-14T18:53:04Z")

</div>

Hi @nirmaltiwari139,

Were you able to verify that you are using the new token and not one that has expired? Would you be able to compare the two before making the API call?

---

<div class="post-metadata">

**Author:** ![nirmaltiwari139](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/nirmaltiwari139/32/43815_2.png) [@nirmaltiwari139](https://devforum.zoom.us/u/nirmaltiwari139)\
**Post date:** [December 15, 2022, 10:07am UTC](https://devforum.zoom.us/t/code-124-message-invalid-access-token-error-for-user-creation-api-using-asp-net-api-call/80315/4 "2022-12-15T10:07:45Z")

</div>

> [@nirmaltiwari139](#):
>
> ```auto
> var secToken = new JwtSecurityToken(header, payload);
> var handler = new JwtSecurityTokenHandler();
> 
> // Token to String so you can use it in your client
> var tokenString = handler.WriteToken(secToken);
> 
> return tokenString;
> 
> ```

Api call return token not matching with the existing token so only iam getting the error.

---

<div class="post-metadata">

**Author:** ![nirmaltiwari139](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/nirmaltiwari139/32/43815_2.png) [@nirmaltiwari139](https://devforum.zoom.us/u/nirmaltiwari139)\
**Post date:** [December 15, 2022, 3:40pm UTC](https://devforum.zoom.us/t/code-124-message-invalid-access-token-error-for-user-creation-api-using-asp-net-api-call/80315/5 "2022-12-15T15:40:36Z")

</div>

iam unable to comapre the token . thats the issue ?

---

<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:** [December 19, 2023, 7:16am UTC](https://devforum.zoom.us/t/code-124-message-invalid-access-token-error-for-user-creation-api-using-asp-net-api-call/80315/6 "2023-12-19T07:16:45Z")

</div>

Closed on December 19, 2023, 7:16am UTC

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