agoraio-community / agora-node-tokenserver Goto Github PK
View Code? Open in Web Editor NEWA simple token server for Agora applications using NodeJS with Express, and Agora Access Token modules.
License: MIT License
A simple token server for Agora applications using NodeJS with Express, and Agora Access Token modules.
License: MIT License
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
at new NodeError (node:internal/errors:371:5)
at Function.from (node:buffer:322:9)
at AccessToken.build (C:\Users\HP\Desktop\Agora-Node-TokenServer\node_modules\agora-access-token\src\AccessToken.js:31:21)
at Function.buildTokenWithAccount (C:\Users\HP\Desktop\Agora-Node-TokenServer\node_modules\agora-access-token\src\RtcTokenBuilder.js:70:25)
at Function.buildTokenWithUid (C:\Users\HP\Desktop\Agora-Node-TokenServer\node_modules\agora-access-token\src\RtcTokenBuilder.js:40:21)
at generateRTCToken (C:\Users\HP\Desktop\Agora-Node-TokenServer\index.js:59:29)
at Layer.handle [as handle_request] (C:\Users\HP\Desktop\Agora-Node-TokenServer\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\HP\Desktop\Agora-Node-TokenServer\node_modules\express\lib\router\route.js:137:13)
at nocache (C:\Users\HP\Desktop\Agora-Node-TokenServer\index.js:15:3)
at Layer.handle [as handle_request] (C:\Users\HP\Desktop\Agora-Node-TokenServer\node_modules\express\lib\router\layer.js:95:5)
Picked up your code and ran it after adding my APP ID and APP CERTIFICATE. but this error shows up when I try to use the URLs that you have provided like: http://localhost:8080/rtc/test/publisher/uid/1
Something changed after using this: http://localhost:8080/rtc/:test/:publisher/uid/1
and the out became // 20220212032023
// http://localhost:8080/rtc/:test/:publisher/uid/1
{
"error": "role is incorrect"
}
even though the role is correct. I even tried audience as the role but the output didn't change.
and the ping: http://localhost:8080/ping works just fine and produces this output:
// 20220212032146
// http://localhost:8080/ping
{
"message": "pong"
}
Can you please help me with this? I shall be very thankful.
Hello,
Based on your sample code, I integrated the RTC and RTM token generation in my web application which is served via express.js for server side. I successfully arrive to generate and retrieve the tokens, but when I pass the RTC or RTM in the RTCclient.join channel function, it doesn't work.
app.get('/rte/:channel/:role/:tokentype/:uid/', nocache , generateRTEToken);
In my script "webvr-broadcast-client.js", I improved the function JoinChannel()
with the token request.
function joinChannel() {
fetch("https://example.com/rte/web/publisher/uid/44/").then(function(response) {
return response.json();
}).then(function(data) {
token = data.rtcToken; (RTC or RTM are well retrieved)
rtcClient.setClientRole('audience', () => {
console.log('Client role set to audience');
}, (e) => {
console.log('setClientRole failed', e);
});
rtcClient.join(token, channelName, 0, (uid) => {
console.log('User ' + uid + ' join channel successfully');
localStreams.uid = uid;
createBroadcaster(uid); // Load 3D model with video texture
createCameraStream(uid); // Create the camera stream
joinRTMChannel(uid); // join the RTM channel
}, (err) => {
console.log('[ERROR] : join channel failed', err);
});
}).catch(function() {
});
}
The error returned is :
"Get server node failed [NO_AUTHORIZED]" โ "https://webrtc2-ap-web-2.agoraio.cn/api/v1" โ "NO_AUTHORIZED"
I confirm the code structure work, by using a Temp RTC Token it works very well.
But when I pass a generated RTC or RTM token as parameter, it doesn't work.
At this stage you can reproduce the scenario by replacing the joinChannel() function and creating a "token" variable ( var token = "";) on top of the file.
We will be happy to know how to resolve that:)
RtmTokenBuilder.buildToken fails with a crash in gcloud functions.
Rtc token is successfully generated.
Cloned the repository, replaced APP_ID
, and APP_CERTIFICATE
with my own. The following error is shown when trying to access the /access_token
endpoint: http://localhost:8080/access_token?channelName=testchannel
:
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
at Function.from (buffer.js:330:9)
at AccessToken.build (/Users/<omitted>/Agora-Node-TokenServer/node_modules/agora-access-token/src/AccessToken.js:31:21)
at Function.buildTokenWithAccount (/Users/<omitted>/Agora-Node-TokenServer/node_modules/agora-access-token/src/RtcTokenBuilder.js:70:25)
at Function.buildTokenWithUid (/Users/<omited>/Agora-Node-TokenServer/node_modules/agora-access-token/src/RtcTokenBuilder.js:40:21)
at generateAccessToken (/Users/<omitted>/Agora-Node-TokenServer/index.js:47:33)
at Layer.handle [as handle_request] (/Users/<omitted>/Agora-Node-TokenServer/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/<omitted>/Agora-Node-TokenServer/node_modules/express/lib/router/route.js:137:13)
at nocache (/Users/<omitted>/Agora-Node-TokenServer/index.js:15:3)
at Layer.handle [as handle_request] (/Users/<omitted>/Agora-Node-TokenServer/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/<omitted>/Agora-Node-TokenServer/node_modules/express/lib/router/route.js:137:13)
i have try the same code here but still i am getting
Internal Server Error
i have even use another the code you provided in the youtube still given the error...https://www.youtube.com/watch?v=KcLypppA2IQ i have also try this code but still is not working....
please if you can help me, i am also open a question in stackoverflow, here is the link
https://stackoverflow.com/questions/73084024/agora-token-error-could-not-handle-the-request
thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.