Closed HuuNguyen312 closed 7 years ago
// Set the following constants to your OpenTok API key and API secret.
// See https://tokbox.com/account/.
OpenTok sdk = new OpenTok(API_KEY, API_SECRET);
SessionProperties sessionProperties = new SessionProperties.Builder()
.mediaMode(MediaMode.ROUTED)
.build();
Session session = sdk.createSession(sessionProperties);
String sessionId = session.getSessionId();
not work
Creating the session from the Android App is not a recommended practice.
Doing that, will require to bundle the API_SECRET
inside your app and some third party could get it and use it without permission.
The recommended way is to setup a server side where you will get the sessions using the appropriate server sdk. The Android app will communicate with it to fetch the sessionId and the token.
For more details, please take a look to our current tutorial: https://tokbox.com/developer/tutorials/android/
I know about security reason but i must do a demo project for 5 days, and I'm strong with Java but not familiar with server side, how to create and deploy a new server to a host (which host?).
Any workaround solution for me? Thanks!
Hi @nhoxbypass,
Please, take a look at the tutorial: https://tokbox.com/developer/tutorials/android/basic-video-chat/#server
Thanks @marinaserranomontes so we must use server sdk anyway. Client sdk cannot generate session id.
Exactly. You have to use the server for a production application. You should not hardcode the credentials in your production app because the sessionIds cannot be created dynamically and tokens expire.
Thank you very much, the documents about Server SDK is also too good. Many thanks~
Hi
How to generate Session ID and TOKEN by programmatically in Android