Problem of meetingsdk authentication with jwt token ios

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/ but same issue.

@streamerz.ltd

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

Zoom SDK version: v5.15.7.9685

Here is sample token CnsKCiJhbGciOiAiSFMyNTYiLAoKInR5cCI6ICJKV1QiCgp9Cg.CnsKCiJhcHBLZXkiOiAicnBhRjRYWlpUUlNXYjJyM0d1Vm53IiwKInNka0tleSI6ICJycGFGNFhaWlRSU1diMnIzR3VWbnciLAogInJvbGUiOiAiMCIsCgoibW4iOiAiODkyMTE3Mzc1MTUiLAoKImlhdCI6ICIxNjkyMjY5MDg3OTcxIiwKCiJleHAiOiAiMTY5MjM1NTQ4Nzk3MSIsCgoidG9rZW5FeHAiOiAiMTY5MjM1NTQ4Nzk3MSIsCgoidXNlcklEIjogIjEyMzQ1Njc4OTAiLAoKInVzZXJOYW1lIjogIkpvaG4gRG9lIgoKfQo.lJI10tK-nkBoXVsvOV_c4NbjXKoJVtRJ8dA0ZfyMmHk

@streamerz.ltd ,

Your iat, exp and tokenExp are invalid integer values

image

Here’s a valid one in comparison
image

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