webex / webex-android-sdk-example

A developer friendly sample implementation of Webex client SDK and showcases all SDK features.
MIT License
13 stars 23 forks source link

JWT-Authentication doesnt work anymore since SDK 3.0.0 #28

Open fhartmann-erp opened 3 years ago

fhartmann-erp commented 3 years ago

When using the same JWT which works with SDK-Version 2.8.0 i always get the error: "JWT Login Failed". When debugging the Error of the jwtAuthenticator.authorize method says error code -7000 "UNEXPECTED_ERROR".

ankibatr commented 3 years ago

@fhartmann-erp

  1. Have you called initialize API before calling any webex API as mentioned in Migration-Guide-for-v2-to-v3?

NOTE: We need to wait for the response of webex.initialize API. After getting the response we need to decide whether we are already logged in or we need to authorize the user.

ReadMe Doc

fhartmann-erp commented 3 years ago

I used it like in this example: webex.initialize(CompletionHandler { result -> if (result.error != null) { //already authorised } else { authenticator.authorize(loginWebview, CompletionHandler { result -> if (result.error != null) { //Handle the error }else{ //Authorization successful } }) } })

I also tried it with the KitchenSink Sample App by just pasting a JWT which worked in previous versions and got the same error like mentioned before.

ankibatr commented 3 years ago

How you generated the JWT token?

fhartmann-erp commented 3 years ago

With the package io.jsonwebtoken for Android. Also created a JWT Token manually on https://jwt.io/ and it also does not work

fhartmann-erp commented 3 years ago

Found this in the logs:

2021-06-14 08:31:38.809 9022-9022/com.cisco.sdk_android D/WBX_TEAMS-ch: [FUNCTION_CALL] ZygoteInit.java::1386 main:IOmniusServiceBridge.loginWithJWT()
2021-06-14 08:31:38.815 9022-9094/com.cisco.sdk_android D/WBX_TEAMS-ucf: tid[548225411736] OmniusService.cpp::194 loginWithJWT:Unable to parse Guest Issuer JWT

The JWT-Token i used was working fine in SDK Version 2.8.0. Is there something that got changed where the JWT gets Validated/Parsed?

ankibatr commented 3 years ago

Does your payload looks like below example? https://developer.webex.com/docs/guest-issuer

Screenshot 2021-06-14 at 12 30 27 PM
fhartmann-erp commented 3 years ago

I adjusted my payload and in the sample app the token works now but when using the sdk in my java based android application i get an unexpected error -7000 at webex.initialize. After that the app always crashes when initiating a call: E/libc++abi: terminating with uncaught exception of type spark::expired_reference_exception: NSt6__ndk18weak_ptrI17ITelephonyServiceEE reference has expired A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 30574 (plus.vrvideoapp)

ankibatr commented 3 years ago

You can not use the Webex APIs until authorised successful (cached or fresh login): webex.initialize(CompletionHandler { result -> if (result.error != null) { //already authorised } else { authenticator.authorize(loginWebview, CompletionHandler { result -> if (result.error != null) { //Handle the error }else{ //Authorization successful } }) } })

fhartmann-erp commented 3 years ago

When trying to authorize, even if the initialization-Method throws an error, i get the following error in the logs: 2021-06-14 12:58:32.325 1062-1108/com.erpplus.vrvideoapp E/WBX_TEAMS-ucf: tid[547549303888] OmniusAdapter.cpp::212 operator():Failed to fetch AccessToken from JWT 2021-06-14 12:58:32.331 1062-1112/com.erpplus.vrvideoapp D/Authorize:: null

The same token works in the sample app but not when using the sdk in my java android application

adamrangs commented 3 years ago

@jbenyovs - request you to please help setup a call with @fhartmann-erp for us to do a screen share

jbenyovs commented 3 years ago

@adamrangs I have setup a Webex space with you and @fhartmann-erp to discuss the details of a call.

fhartmann-erp commented 3 years ago

I think i've got it to work, i copied the permissions in the AndroidManifest.xml from the Example App in my App and then the authentication works and i could make a call. Is there any new permissions the WebexSDK needs in the newer version?

ankibatr commented 3 years ago

Good to hear that it works for you.

fhartmann-erp commented 3 years ago

Seems like the Internet-Permission was missing, didnt need that for the SDK Version 2.8.0. Also, when the app gets launched for the first time the initialize-Method always throws an "Unexpected Error -7000", but if i call the authenticate-Method anyways, it works. Launching the app for the second time, the initialize-Method doesnt throw an error.

Ramaraju1992 commented 3 years ago

I am facing same issue while authenticating JWT token, and error message logged below.

D/WBX_TEAMS-ch: [FUNCTION_CALL] ZygoteInit.java::930 main:IOmniusServiceBridge.getGuestIssuerJwtExpiration() D/WBX_TEAMS-ch: [FUNCTION_RETURN] ZygoteInit.java::930 main:<-- 7ms IOmniusServiceBridge.getGuestIssuerJwtExpiration(): void D/WBX_TEAMS-ch: [FUNCTION_CALL] ZygoteInit.java::930 main:IOmniusServiceBridge.getGuestIssuerJwtExpiration() D/WBX_TEAMS-ch: [FUNCTION_RETURN] ZygoteInit.java::930 main:<-- 7ms IOmniusServiceBridge.getGuestIssuerJwtExpiration(): void W/System.err: java.lang.IllegalStateException: bridge.guestIssuerJwtExpiration must not be null W/System.err: at com.ciscowebex.androidsdk.OmniusWrapper.getGuestIssuerJwtExpiration(OmniusWrapper.kt:211) W/System.err: at com.ciscowebex.androidsdk.auth.JWTAuthenticator.isAuthorized(JWTAuthenticator.kt:44) W/System.err: at com.example.asterciscokotlin.MainActivity$onCreate$1.onClick(MainActivity.kt:29)

Error messages debugging isjava.lang.IllegalStateException: bridge.guestIssuerJwtExpiration must not be null

fhartmann-erp commented 3 years ago

Since SDK 3.0.0 you have to set the expiration of the JWT. In the previous version it worked without setting the expiration.