# onMobileRTCAuthReturn never gets called on a valid JWT token

**URL:** <https://devforum.zoom.us/t/onmobilertcauthreturn-never-gets-called-on-a-valid-jwt-token/94843>\
**Category:** iOS\
**Created:** [September 11, 2023, 3:57pm UTC](https://devforum.zoom.us/t/onmobilertcauthreturn-never-gets-called-on-a-valid-jwt-token/94843 "2023-09-11T15:57:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SunriseSoftware](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@SunriseSoftware](https://devforum.zoom.us/u/SunriseSoftware)\
**Post date:** [September 11, 2023, 3:57pm UTC](https://devforum.zoom.us/t/onmobilertcauthreturn-never-gets-called-on-a-valid-jwt-token/94843/1 "2023-09-11T15:57:02Z")

</div>

**Description**  
I’m trying to integrate the iOS Meeting SDK, but I can’t authenticate the SDK with a JWT token.  
The tokens are generated from our backend (as recommended) and I confirm they are valid.  
They did work with `MobileRTCSample` and also my integration of Android Meeting SDK.

When I pass a valid JWT token and call `authService.sdkAuth()`, `onMobileRTCAuthReturn` from the delegate never gets called.  
The weird thing is when I pass a expired JWT token, `onMobileRTCAuthReturn` is actually called and give this error `MobileRTCAuthError_TokenWrong` which is correct.  
I don’t understand what I am missing here, I don’t see any major difference between the sample project and mine.

Thanks in advance for your help!

**Which iOS Meeting SDK version?**  
5.15.12

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

1. Call `authService.sdkAuth()` with a valid JWT token
2. `onMobileRTCAuthReturn` don’t get called

**Code**

```swift
class ZoomSDK: NSObject {
    private let instance = MobileRTC.shared()
    private var continuation: CheckedContinuation<MobileRTCAuthError, Never>?
    
    func authenticate(domain: String, jwtToken: String) async -> Bool {
        let context = MobileRTCSDKInitContext()
        context.domain = "zoom.us"
        context.enableLog = true
        context.locale = .default
        guard instance.initialize(context) else {
            Log.shared.e(message: "Could not initialize MobileRTC")
            return false
        }
        guard let authService = instance.getAuthService() else { return false }
        authService.delegate = self
        authService.jwtToken = jwtToken

        let value: MobileRTCAuthError = await withCheckedContinuation { continuation in
            self.continuation = continuation
            authService.sdkAuth()
        }
        return value == MobileRTCAuthError.success
    }    
}

extension ZoomSDK: MobileRTCAuthDelegate {
        
    func onMobileRTCAuthReturn(_ returnValue: MobileRTCAuthError) {
        print("onMobileRTCAuthReturn() - return: \(returnValue)")
        self.continuation?.resume(returning: returnValue)
    }   
}

```

---

<div class="post-metadata">

**Author:** ![ayeshasananjerjeez](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@ayeshasananjerjeez](https://devforum.zoom.us/u/ayeshasananjerjeez)\
**Post date:** [September 28, 2023, 3:04am UTC](https://devforum.zoom.us/t/onmobilertcauthreturn-never-gets-called-on-a-valid-jwt-token/94843/2 "2023-09-28T03:04:16Z")

</div>

The issue seems to be related to the `MobileRTC.shared().initialize` method. Ensure that you call `initialize` only once during app startup, as calling it multiple times can lead to SDK authentication issues. Also, confirm that you are using the correct domain for the `MobileRTCSDKInitContext`.

---

<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:** [October 28, 2023, 1:04pm UTC](https://devforum.zoom.us/t/onmobilertcauthreturn-never-gets-called-on-a-valid-jwt-token/94843/3 "2023-10-28T13:04:28Z")

</div>

Closed on October 28, 2023, 1:04pm UTC

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