08-10-2022 02:52 AM - last edited on 03-16-2023 05:13 AM by Shahzad_Ismail
Can I use the latest iOS SDK (SinchRTC 5.11.6) with the "Legacy Voice, Video, and Verification" service?
I'm in a process of updating our iOS app from SinchRTC 4.2.11 SDK and while implementing the new JSON Web Token authentication process I hit a wall. I think I'm creating the JWTs correctly, but I'm always getting 401 errors from `clientDidFail(_: SINClient!, error: Error!)` delegate method:
Error Domain=SINErrorDomainApi Code=401 "401 (401)" UserInfo={NSLocalizedDescription=401 (401), serverReference=f32fc19e-2801-406f-8116-671cc1262720, serverMessage=401, httpStatusCode=401, ocraErrorCode=401}
I'm afraid this might be caused by our account being still a legacy one, it's registered at pawel.dudek@toptal.com
Solved! Go to Solution.
08-11-2022 01:58 AM - last edited on 08-11-2022 02:00 AM by Shahzad_Ismail
The information you provide above shows the following error in our logs:
Authentication failure: IDX10501: Signature validation failed. Unable to match key: kid: 'System.String'.
Within our iOS distribution you will find our Swift sample app, dynamic/SinchRTC/samples/VideoCallKitSwift:
https://download.sinch.com/ios/5.12.5/SinchRTC-iOS-5.12.5%2b6f51d567.tar.bz2
There you will find an example for how to create the JWT with Swift and you can also run the sample to verify you credentials.
08-10-2022 05:24 AM - last edited on 08-10-2022 06:31 AM by Shahzad_Ismail
Hi Blazej,
You should be able to use the same credentials you used with the legacy SDK.
Here are some additional documentation for creating and signing your JWT:
https://github.com/sinch/sinch-rtc-api-auth-examples
https://developers.sinch.com/docs/in-app-calling/ios/auth/
https://developers.sinch.com/docs/in-app-calling/ios-android-cloud-migration/
Let me know if you still have issues after looking through the docs.
08-10-2022 07:09 AM
Hi Andreas,
I've looked into your Python example and I think I'm doing exactly the same, just in Swift. Perhaps I'm using wrong backend address. It used to be `sandbox.sinch.com` for debugging and `clientapi.sinch.com` for production. At the moment I'm only testing a debugging build against `ocra.api.sinch.com`, is this fine?
Also, the error I get is not very descriptive but maybe you could check your server logs and tell me what's wrong with my JWT? My app ID is `f4016904-df1d-4ffb-ad3a-95e525e9e13a` and here is exactly the error code I'm getting:
{
"error": {
"code": 401,
"message": "401",
"reference": "127e6693-b7f4-457d-99dc-f81c43f93c9a"
}
}
08-10-2022 07:22 AM
I just used a sniffer to intercept the JWT that goes to your servers and verified with jwt.io that it looks as expected (at least AFAIU) and is correctly signed. Here it is: https://jwt.io/#debugger-io?token=eyJraWQiOiJoa2RmdjEtMjAyMjA4MTAiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIvL...
08-11-2022 01:58 AM - last edited on 08-11-2022 02:00 AM by Shahzad_Ismail
The information you provide above shows the following error in our logs:
Authentication failure: IDX10501: Signature validation failed. Unable to match key: kid: 'System.String'.
Within our iOS distribution you will find our Swift sample app, dynamic/SinchRTC/samples/VideoCallKitSwift:
https://download.sinch.com/ios/5.12.5/SinchRTC-iOS-5.12.5%2b6f51d567.tar.bz2
There you will find an example for how to create the JWT with Swift and you can also run the sample to verify you credentials.
08-11-2022 06:15 AM
Hi Andreas, thank you! Your sample Swift code indeed is able to authenticate against `ocra.api.sinch.com`. I tested both tokens with jwt.io and they have the same content, so I don't really get where's the difference. Anyway, I'll just continue using your sample. Thank you!
08-11-2022 06:34 AM
Great stuff, let me know if you need something else