Mhd Omar Bahra
Mhd Omar Bahra

Reputation: 39

How to do screen sharing in agora without getting an authentication problem

I've implemented the agora sdk 3.0 for video calls.

now I'm trying to get screen sharing to work, but I keep getting the error provided in the picture below (Join failed: NO_AUTHORIZED).

Picture of console while sharing a screen

screen sharing code sample:

async shareScreen() {
  this.shareClient = AgoraRTC.createClient({
    mode: 'rtc',
    codec: 'vp8'
  })

  this.shareClient.init('xxxxxxxxxxxxxx', () => {
    this.shareClient.join('same token video call started with', 'same room name of current outgoing video call', null, (uid) => {
      const streamSpec = {
        streamID: uid,
        audio: false,
        video: false,
        screen: true
      }
      if (isFirefox()) {
        streamSpec.mediaSource = 'window';
      } else if (!isCompatibleChrome()) {
        streamSpec.extensionId = 'minllpmhdgpndnkomcoccfekfegnlikg';
      }
      this.shareScreenStream = AgoraRTC.createStream(streamSpec);
      // Initialize the stream.
      this.shareScreenStream.init(() => {
        // Play the stream.
        this.shareScreenStream.play('renderer');
        // Publish the stream.
        this.shareClient.publish(this.shareScreenStream);

      }, function(err) {
        console.log(err);
      });

    }, function(err) {
      console.log(err);
    })
  });
},

Upvotes: 1

Views: 727

Answers (1)

Ekaansh Arora
Ekaansh Arora

Reputation: 1314

The screensharing client should use an unique token based on the UID and channel name. Not the one the main user is using.

Upvotes: 1

Related Questions