I've been following along with this https://github.com/songz/OpenTokNodeJS

I posted an issue but thought I would try here as well.

I've been working at this for a minute and can't seem to get it running. Here's my error

TypeError: Object Error: Invalid Key or Secret has no method 'createSession'
    at port (/Users/rswain/Desktop/Art/videotok/app.js:42:19)
    at callbacks (/Users/rswain/Desktop/Art/videotok/node_modules/express/lib/router/index.js:164:37)
    at param (/Users/rswain/Desktop/Art/videotok/node_modules/express/lib/router/index.js:138:11)
    at param (/Users/rswain/Desktop/Art/videotok/node_modules/express/lib/router/index.js:135:11)
    at pass (/Users/rswain/Desktop/Art/videotok/node_modules/express/lib/router/index.js:145:5)
    at Router._dispatch (/Users/rswain/Desktop/Art/videotok/node_modules/express/lib/router/index.js:173:5)
    at Object.router (/Users/rswain/Desktop/Art/videotok/node_modules/express/lib/router/index.js:33:10)
    at next (/Users/rswain/Desktop/Art/videotok/node_modules/express/node_modules/connect/lib/proto.js:193:15)
    at resume (/Users/rswain/Desktop/Art/videotok/node_modules/express/node_modules/connect/lib/middleware/static.js:65:7)
    at SendStream.error (/Users/rswain/Desktop/Art/videotok/node_modules/express/node_modules/connect/lib/middleware/static.js:80:37)
TypeError: Object Error: Invalid Key or Secret has no method 'createSession'
    at port (/Users/rswain/Desktop/Art/videotok/app.js:42:19)
    at callbacks (/Users/rswain/Desktop/Art/videotok/node_modules/express/lib/router/index.js:164:37)
    at param (/Users/rswain/Desktop/Art/videotok/node_modules/express/lib/router/index.js:138:11)
    at param (/Users/rswain/Desktop/Art/videotok/node_modules/express/lib/router/index.js:135:11)
    at pass (/Users/rswain/Desktop/Art/videotok/node_modules/express/lib/router/index.js:145:5)
    at Router._dispatch (/Users/rswain/Desktop/Art/videotok/node_modules/express/lib/router/index.js:173:5)
    at Object.router (/Users/rswain/Desktop/Art/videotok/node_modules/express/lib/router/index.js:33:10)
    at next (/Users/rswain/Desktop/Art/videotok/node_modules/express/node_modules/connect/lib/proto.js:193:15)
    at resume (/Users/rswain/Desktop/Art/videotok/node_modules/express/node_modules/connect/lib/middleware/static.js:65:7)
    at SendStream.error (/Users/rswain/Desktop/Art/videotok/node_modules/express/node_modules/connect/lib/middleware/static.js:80:37)

I'm guessing it has something to do with my api key, and to be honest i'm not 100% where i'm supposed to even put it. I've tried a few methods. First I replaced the lines in app.js

var OTKEY = process.env.TB_KEY; var OTSECRET = process.env.TB_SECRET;

with

var OTKEY = (my api key);
var OTSECRET = (my secret);

but when i run $ node app.js, nothing happens, and I get the error

I've also tried adding the key and secret to the package.json file like so

{
    "name":"NodeOpenTok",
    "version":"0.0.2",
    "dependencies":{
      "opentok":"44456952",
      "express":"7f2ecae114cd4095a1ed689ff63910f1ea79444b",
      "ejs":""
    }
}

but I get the same errors. any ideas?

thanks for making this, looks great, can't wait to get it working!

有帮助吗?

解决方案

my name is Song and I believe I can help you. When I wrote the following code, I am simply setting the variables OTKEY and OT_SECRET.

var OTKEY = process.env.TB_KEY; 
var OTSECRET = process.env.TB_SECRET;

You can similarly replace the key and secret directly:

var OTKEY = "1234";
var OTSECRET = "1abbababaabcabc";

process.env.TB_KEY and process.env.TB_SECRET pulls out the variables from my system environment . I do it this way because of security reasons ( I don't want to accidentally push my key/secret to github ). To set variables for your system environment, open your bash profile and add the following lines:

export TB_KEY='1234'
export TB_SECRET='1abbababaabcabc' 

Again, setting the environment variables is not necessary to get your code to work. The simplest way to go is to simply set the variables OTKEY and OTSECRET.

Good Luck!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top