Skip to content

Commit

Permalink
fix: remove guest endpoint check
Browse files Browse the repository at this point in the history
  • Loading branch information
adamweeks committed May 24, 2024
1 parent 5345358 commit d8b6e22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
6 changes: 2 additions & 4 deletions meeting-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ export const vbgImageUrl = './images/V_B_G.jpg';
// Note - Unless we have this information, this demo cannot join a meeting
export const meetingInfo = {} // REQUIRED

// To get guestIssueAccessToken and guestEndpointUrl
// Update the following with the Guest Issuer Access Token through Service Apps
// Read more about it here: https://developer.webex.com/docs/sa-guest-management
// Note - Unless we have this token, this demo cannot join a meeting
export const guestIssuerAccessToken = ""; // OPTIONAL
export const guestEndpointUrl = ""; //OPTIONAL
export const guestIssuerAccessToken = ""; // REQUIRED or personalAccessToken REQUIRED

//To get access token visit - https://developer.webex.com/docs/getting-started
export const personalAccessToken = ""; // REQUIRED
export const personalAccessToken = ""; // REQUIRED or guestIssuerAccessToken REQUIRED
26 changes: 4 additions & 22 deletions webex.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const remoteAudioStreamElm = document.getElementById('remote-audio');
const localVideoStreamElm = document.getElementById('local-video');
const localAudioStreamElm = document.getElementById('local-audio');

import { meetingInfo, guestEndpointUrl, vbgImageUrl, guestIssuerAccessToken,personalAccessToken } from './meeting-info.js';
import { meetingInfo, vbgImageUrl, guestIssuerAccessToken,personalAccessToken } from './meeting-info.js';

let webex = null;
let createdMeeting = null;
Expand Down Expand Up @@ -42,7 +42,7 @@ rootElement.addEventListener('click', async (e) => {
const guestUrl = 'https://webexapis.com/v1/guests/token';

// Via Service App
async function getGuestAccessTokenV2() {
async function getGuestAccessToken() {
const response = await fetch(guestUrl, {
method: 'post',
headers: {
Expand All @@ -61,24 +61,6 @@ async function getGuestAccessTokenV2() {
return data.accessToken;
}

async function getGuestAccessToken() {
// Create the end point using guest issuer
const response = await fetch(guestEndpointUrl, {
method: 'post',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Guest User',
}),
});

const data = await response.json();

return data.body.token;
}

async function initWebexAndRegisterDevice(access_token) {
if (!access_token) {
alert('Please provide an access token');
Expand Down Expand Up @@ -186,8 +168,8 @@ export async function joinMeeting() {
// Step-1
let accessToken

if(guestEndpointUrl && guestIssuerAccessToken){
accessToken = await getGuestAccessTokenV2();
if(guestIssuerAccessToken){
accessToken = await getGuestAccessToken();
} else{
accessToken = personalAccessToken
}
Expand Down

0 comments on commit d8b6e22

Please sign in to comment.