# Unable to share screen using Get a Room

**URL:** <https://openvidu.discourse.group/t/unable-to-share-screen-using-get-a-room/1217>\
**Category:** Issues developing apps\
**Tags:** v2\
**Created:** [June 18, 2020, 1:30pm UTC](https://openvidu.discourse.group/t/unable-to-share-screen-using-get-a-room/1217 "2020-06-18T13:30:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![umargarga](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/umargarga/32/638_2.png) [@umargarga](https://openvidu.discourse.group/u/umargarga)\
**Post date:** [June 18, 2020, 1:30pm UTC](https://openvidu.discourse.group/t/unable-to-share-screen-using-get-a-room/1217/1 "2020-06-18T13:30:47Z")

</div>

Greetings all,

I’m new to OpenVidu and I can tell it’s amazing.

Unfortunately, I’m unable to Share Screen using OpenVidu Get a Room after following [this link](https://docs.openvidu.io/en/2.14.0/advanced-features/screen-share/).

```auto
function shareMyScreen() {
OV = new OpenVidu();
var sessionScreen = OV.initSession();
console.log("ENTERED SHARE SCREEN FUNCTION")
getToken((token) => {
    sessionScreen.connect(token).then(() => {
        console.log('COMES TO TO THEN FUNCTION');
        var publisher = OV.initPublisher("html-element-id", {videoSource: "screen"});

        publisher.once('accessAllowed', (event) => {
            publisher.stream.getMediaStream().getVideoTracks()[0].addEventListener('ended', () => {
                console.log('User pressed the "Stop sharing" button');
            });
            sessionScreen.publish(publisher);

        });

        publisher.once('accessDenied', (event) => {
            console.warn('ScreenShare: Access Denied');
        });

    }).catch((error => {
        console.warn('There was an error connecting to the session:', error.code, error.message);

    }));
});
console.log("FINISHED SHARE SCREEN FUNCTION")
}

```

![Capture](https://global.discourse-cdn.com/free1/uploads/openvidu/original/1X/fbd02e526d4593b85f076c47e5162283159702f1.png)

I think it might be skipping the getToken because I don’t know how to pass the token.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![CSantosM](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/csantosm/32/16_2.png) [@CSantosM](https://openvidu.discourse.group/u/CSantosM)\
**Post date:** [June 18, 2020, 1:51pm UTC](https://openvidu.discourse.group/t/unable-to-share-screen-using-get-a-room/1217/2 "2020-06-18T13:51:33Z")

</div>

Hello,

The code you pasted is bad formated and it’s difficult to read it. However, there could be a bug in the code… try with:

```
getToken().then((token) => {
   ...
})
```

---

<div class="post-metadata">

**Author:** ![umargarga](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/umargarga/32/638_2.png) [@umargarga](https://openvidu.discourse.group/u/umargarga)\
**Post date:** [June 18, 2020, 2:45pm UTC](https://openvidu.discourse.group/t/unable-to-share-screen-using-get-a-room/1217/3 "2020-06-18T14:45:48Z")

</div>

Thank you. It has fixed my problem. Though, I’ve copied the code above from the OpenVidu share screen documentation.

You’re awesome.

---

<div class="post-metadata">

**Author:** ![CSantosM](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/csantosm/32/16_2.png) [@CSantosM](https://openvidu.discourse.group/u/CSantosM)\
**Post date:** [June 18, 2020, 3:18pm UTC](https://openvidu.discourse.group/t/unable-to-share-screen-using-get-a-room/1217/4 "2020-06-18T15:18:38Z")

</div>

Yes, I just fixed the code from docs.

Thank you
