4

I am getting a 1004 error when trying to run the opentok api on the server, it is running fine on the localhost but when i ran the same code on the server, it gave me this opentok_authentication_error.

I have checked the apikey and serverkey multiple times and they both are correct, and the session id is also the same.

I can publish and subscribe sessions on the localhost, everything is working fine there but when i uploaded my website on the server and ran it their it gave me this error.

I've also checked the token value generated as well and it is the same which is being generated on the opentok website.

For frontend, I am using angular.js, I dont know what I am doing wrong and when it is working fine on localhost why is giving this error when running on a server.

server.js

 Opentok = require('opentok');
 var OTConfig = require('./config/otconfig');
 var opentok = new Opentok(OTConfig.apiKey, OTConfig.secretKey);
 var OT = require('./routes/opentok')(opentok, app);

routes/opentk.js

var OT_config = require('../config/dbconfig');
var express = require('express');
var router = express.Router();

module.exports = function(opentok, app) {

app.post('/opentok/join', function(req, res) {

    var token,
        sessionId = req.body.ot_session,
        tokenOptions = {};

    tokenOptions.role = "publisher";
    tokenOptions.data = "username=" + req.body.name;
    tokenOptions.data += "courseId=" + req.body.course;
    tokenOptions.data += "role=" + req.body.role;

    // Generate a token.
    token = opentok.generateToken(sessionId, tokenOptions);
    res.send(token);
});

}

controller.js

 var opent = opentokService.generateToken(sessionId);
        opent.then(function(data) {
            $rootScope.token = data.data;
        });

opentok service

 return { 
            generateToken: function(id) {

                let info = {
                    name: $rootScope.username,
                    id: id,
                    role: $rootScope.role,
                    ot_session: $rootScope.sessionId 
                }
                return $http({
                    method: 'post',
                    url: '/opentok/join',
                    data: info
                });
            }
        }
user3732588
  • 51
  • 1
  • 6
  • I don't see anything obviously wrong with your code. Can you provide a link to where I can reproduce this problem? – Adam Ullman Dec 04 '17 at 01:01

1 Answers1

0

enter image description here

First, check your opentok account subscription is paused or not if it is paused then do the need full to activate your account.

enter image description here

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103