Invalid access token using WEB vue js

hello @vic.yang

Having issue on the MEETING SDK got an error

Error creating meeting: { code: 124, message: ‘Invalid access token.’ }

im trying to create a meeting and getting the meeting id

here is my code

app.post('/createMeeting', async (req, res) => {
    try {
        const zoomToken = generateZoomToken(); // Generate the token once
        console.log("teroro", zoomToken);
        
        const response = await axios.post('https://api.zoom.us/v2/users/me/meetings', {
            topic: 'test',
            type: 1 // 1 for instant meeting, you can customize it according to your needs
        }, {
            headers: {
                'Authorization': `Bearer ${zoomToken}`
            }
        });
        console.log("awaaa ",response.data)
        res.json(response.data);
    } catch (error) {
        console.error('Error creating meeting:', error.response ? error.response.data : error.message);
        res.status(error.response ? error.response.status : 500).json({ error: 'Failed to create meeting' });
    }
});


function generateZoomToken() {
    const iat = Math.round(new Date().getTime() / 1000) - 30;
    const exp = iat + 60 * 60 * 2

    const oHeader = { alg: 'HS256', typ: 'JWT' }

    const oPayload = {
        sdkKey: API_KEY,
        role: 1,
        iat: iat,
        exp: exp,
        appKey: API_KEY,
        tokenExp: iat + 60 * 60 * 2
    }

    const sHeader = JSON.stringify(oHeader)
    const sPayload = JSON.stringify(oPayload)
    const signature = KJUR.jws.JWS.sign('HS256', sHeader, sPayload, API_SECRET)
    return signature
   
} 

i am a developer of the account and not the owner

1 Like

@enricke Hope you will be fine.

Here are the sessions regarding OAuth :point_down:

Zoom Integration OAuth App Part 1
Zoom Integration OAuth App Part 2

Here :point_down: are the sessions regarding how to schedule meetings using REST API

Create Zoom Meeting - (REST API)
How to Create password less Zoom Meeting -(REST API)
How to Enable Zoom Meeting Registration - (REST API)

Here are the sessions regarding WebSDK Integrations

Hey thanks for replying so this is my situation i wanted to create an app that let a host create stream and people can watch it without creating any account like public viewing

Flow would be
Click the button “Spectate” and then show the stream and done

@enricke ,

Could I confirm if you are using the correct keys for the token generation?

You will either need

  • Meeting SDK App or
  • General App

Within either of these apps, there is a pair of Client ID and Client Secret which can be used to generate the Auth token

i fixed this with creating a server-to-arever -auth

@enricke alright, thanks for the update.

is there a way i can put this on a webview on expo?