playframework 2.0 - How to process Twilio 'Programmable video' JWT access token correctly? (Android) -


i trying embed twilio's programmable video android app.

i've created endpoint on java server, uses "com.twilio.sdk" % "twilio-java-sdk" % "6.3.0" library obtaining access tokens following code:

private static final string account_sid = "acxxxxx"; private static final string api_key_sid = "skxxxxx"; private static final string api_key_secret = "aa8xxxxx"; private static final string twilio_configuration_sid = "vsxxxxx";  public result token(string identity) {     return ok(json.tojson(new responsemessage(createtoken(identity)))); }  public static string createtoken(string identity) {     conversationsgrant grant = new conversationsgrant();     grant.configurationprofilesid = twilio_configuration_sid;      accesstoken token = new accesstoken.builder(             account_sid,             api_key_sid,             api_key_secret     ).identity(identity).grant(grant).ttl(86400).build();      return token.tojwt(); } 

then receiving token in android app endpoint, , instantiating accessmanager token

new accessmanager(myactivity.this,             videotoken,             new accessmanager.listener() {         @override         public void ontokenexpired(accessmanager twilioaccessmanager) {             //expired :(         }          @override         public void ontokenupdated(accessmanager twilioaccessmanager) {             //updated!         }); 

, , trying create twilioconversationsclient following code in accessmanagerlistener:

twilioconversationsclient.create(twilioaccessmanager, new twilioconversationsclient.listener() {         @override         public void onstartlisteningforinvites(twilioconversationsclient conversationsclient) {             log.d(tag, "twilioconversationsclient.listener: onstartlisteningforinvites");         }          @override         public void onstoplisteningforinvites(twilioconversationsclient conversationsclient) {             log.d(tag, "twilioconversationsclient.listener: onstoplisteningforinvites");         }          @override         public void onfailedtostartlistening(twilioconversationsclient conversationsclientd,                                              twilioconversationsexception e) {             log.d(tag, "twilioconversationsclient.listener: onfailedtostartlistening");         }); 

evetytime getting 'onfailedtostartlistening' callback error message:

com.twilio.conversations.twilioconversationsexception: code:103, message: 31201 authentication failed

the strangest thing, if copy new token '//updated!' block (see above), , paste code manually in

new accessmanager(myactivity.this,             videotoken 

instead videotoken, receiving server seconds before, works smooth, , getting onstartlisteningforinvites callback. maybe wrong server encoding or encoding when trying read answer? spend few days, still can't resolve problem.

and more, tried replace java server code php, , got same result! if generating token in console (terminal), , pasting android app code, works good. if trying token remote server, getting same error 'code:103, message: 31201 authentication failed'.

i using integrations twilio voice, , ip-messaging, , i've never had problems tokens.

if decode jwt tokens (one server, , generated locally), see difference time of creation , expiration time:

enter image description here

any suggestions appreciated!

finally guys twilio gave workaround. ttl 86400 reason couldn't correctly processed twilio servers. ttl half of lifetime works fine.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -