# Problem of meetingsdk authentication with jwt token ios

**URL:** <https://devforum.zoom.us/t/problem-of-meetingsdk-authentication-with-jwt-token-ios/93537>\
**Category:** iOS\
**Created:** [August 17, 2023, 7:47am UTC](https://devforum.zoom.us/t/problem-of-meetingsdk-authentication-with-jwt-token-ios/93537 "2023-08-17T07:47:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![streamerz.ltd](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/streamerz.ltd/32/51174_2.png) [@streamerz.ltd](https://devforum.zoom.us/u/streamerz.ltd)\
**Post date:** [August 17, 2023, 7:47am UTC](https://devforum.zoom.us/t/problem-of-meetingsdk-authentication-with-jwt-token-ios/93537/1 "2023-08-17T07:47:50Z")

</div>

Generating Token with in app by this way

func generateSignature(key: String, secret: String, meetingNumber: Int, role: Int) → String? {

```
    let currentDate = Date()
    var dateComponent = DateComponents()
    dateComponent.day = 1
    
    let expireDate = Calendar.current.date(byAdding: dateComponent, to: currentDate) ?? Date()
    
    let iat = Int((currentDate.timeIntervalSince1970) * 1000)
    // let iat = Int((Date().timeIntervalSince1970)) - 30
    
    let exp = Int((expireDate.timeIntervalSince1970) * 1000)
    
    let header = """

{

"alg": "HS256",

"typ": "JWT"

}

"""
    
    let payload = """

{

"appKey": "\(key)",
"sdkKey": "\(key)",
 "role": "0",

"mn": "\(meetingNumber)",

"iat": "\(iat)",

"exp": "\(exp)",

"tokenExp": "\(exp)",

"userID": "1234567890",

"userName": "John Doe"

}

"""
    
    guard let headerData = header.data(using: .utf8),
          
            let payloadData = payload.data(using: .utf8) else {
        
        return nil
        
    }
    
    let base64UrlEncodedHeader = headerData.base64EncodedString()
    
        .replacingOccurrences(of: "+", with: "-")
    
        .replacingOccurrences(of: "/", with: "_")
    
        .replacingOccurrences(of: "=", with: "")
    
    let base64UrlEncodedPayload = payloadData.base64EncodedString()
    
        .replacingOccurrences(of: "+", with: "-")
    
        .replacingOccurrences(of: "/", with: "_")
    
        .replacingOccurrences(of: "=", with: "")
    
    let signatureData = HMAC<SHA256>.authenticationCode(for: (base64UrlEncodedHeader + "." + base64UrlEncodedPayload).data(using: .utf8)!, using: SymmetricKey(data: secret.data(using: .utf8)!))
    
    let base64UrlEncodedSignature = Data(signatureData).base64EncodedString()
    
        .replacingOccurrences(of: "+", with: "-")
    
        .replacingOccurrences(of: "/", with: "_")
    
        .replacingOccurrences(of: "=", with: "")
    
    let jwtToken = "\(base64UrlEncodedHeader).\(base64UrlEncodedPayload).\(base64UrlEncodedSignature)"
    
    return jwtToken
    
}

```

ERROR: **MobileRTCAuthError(rawValue: 11).**

we had also generate token by [https://jwt.io/](https://jwt.io/) but same issue.

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [August 17, 2023, 10:33am UTC](https://devforum.zoom.us/t/problem-of-meetingsdk-authentication-with-jwt-token-ios/93537/2 "2023-08-17T10:33:39Z")

</div>

@streamerz.ltd

What version of iOS SDK are you using?  
and do you have a sample of your JWT token as well?

---

<div class="post-metadata">

**Author:** ![streamerz.ltd](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/streamerz.ltd/32/51174_2.png) [@streamerz.ltd](https://devforum.zoom.us/u/streamerz.ltd)\
**Post date:** [August 17, 2023, 10:45am UTC](https://devforum.zoom.us/t/problem-of-meetingsdk-authentication-with-jwt-token-ios/93537/3 "2023-08-17T10:45:19Z")

</div>

Zoom SDK version: v5.15.7.9685

Here is sample token **CnsKCiJhbGciOiAiSFMyNTYiLAoKInR5cCI6ICJKV1QiCgp9Cg.CnsKCiJhcHBLZXkiOiAicnBhRjRYWlpUUlNXYjJyM0d1Vm53IiwKInNka0tleSI6ICJycGFGNFhaWlRSU1diMnIzR3VWbnciLAogInJvbGUiOiAiMCIsCgoibW4iOiAiODkyMTE3Mzc1MTUiLAoKImlhdCI6ICIxNjkyMjY5MDg3OTcxIiwKCiJleHAiOiAiMTY5MjM1NTQ4Nzk3MSIsCgoidG9rZW5FeHAiOiAiMTY5MjM1NTQ4Nzk3MSIsCgoidXNlcklEIjogIjEyMzQ1Njc4OTAiLAoKInVzZXJOYW1lIjogIkpvaG4gRG9lIgoKfQo.lJI10tK-nkBoXVsvOV\_c4NbjXKoJVtRJ8dA0ZfyMmHk**

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [August 17, 2023, 11:21am UTC](https://devforum.zoom.us/t/problem-of-meetingsdk-authentication-with-jwt-token-ios/93537/4 "2023-08-17T11:21:16Z")

</div>

> [@streamerz.ltd](#):
>
> CnsKCiJhbGciOiAiSFMyNTYiLAoKInR5cCI6ICJKV1QiCgp9Cg.CnsKCiJhcHBLZXkiOiAicnBhRjRYWlpUUlNXYjJyM0d1Vm53IiwKInNka0tleSI6ICJycGFGNFhaWlRSU1diMnIzR3VWbnciLAogInJvbGUiOiAiMCIsCgoibW4iOiAiODkyMTE3Mzc1MTUiLAoKImlhdCI6ICIxNjkyMjY5MDg3OTcxIiwKCiJleHAiOiAiMTY5MjM1NTQ4Nzk3MSIsCgoidG9rZW5FeHAiOiAiMTY5MjM1NTQ4Nzk3MSIsCgoidXNlcklEIjogIjEyMzQ1Njc4OTAiLAoKInVzZXJOYW1lIjogIkpvaG4gRG9lIgoKfQo.lJI10tK-nkBoXVsvOV\_c4NbjXKoJVtRJ8dA0ZfyMmHk

@streamerz.ltd ,

Your iat, exp and tokenExp are invalid integer values

![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/0/d/0db7652c34a40417a7df61ef32d62439d0015bf5.png)

Here’s a valid one in comparison  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/9/e/9ef4fb26cc42f5f6d26187d383e0580b0c43caa8.png)

---

<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 16, 2023, 9:21pm UTC](https://devforum.zoom.us/t/problem-of-meetingsdk-authentication-with-jwt-token-ios/93537/5 "2023-09-16T21:21:29Z")

</div>

Closed on September 16, 2023, 9:21pm UTC

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