Signature is invalid error

I am getting the invalid signature error in laravel. I am using Firebase JWT to generate the signature. Here is some of my code.

    public function generateSignature(Request $request) {

        $key = env('ZOOM_SDK_KEY');
        $secret = env('ZOOM_SDK_SECRET');
        $meeting_number = $request->meetingNumber;
        $role = $request->role;
        $iat = time();
        $exp = $iat + 3600;

        $payload = [
            'sdkKey' => $key,
            'mn' => $meeting_number,
            'role' => $role,
            'iat' => $iat,
            'exp' => $exp,
            'tokenExp' => $exp
        ];
        $encode = JWT::encode($payload, $secret, 'HS256');

        Log::info('encode',['data'=>$encode]);
        return response()->json(['signature' => $encode]);
    }

I cloned the demo app from github and ran it, the CDN one but got the same Invalid signature error there also.
Note: I am using correct CLIENT_ID and CLIENT_SECRET by going into general app type.
Also is it something related to publishing app or adding the app, I am new to zoom and really confused about what is going wrong. Sorry for such a big paragraph but I need help. Even a small help will really be appreciated. Also below I am providing function through which I am creating meeting.

    public function getZoomAccessToken()
    {
        $clientId = env('ZOOM_CLIENT_KEY');
        $clientSecret = env('ZOOM_CLIENT_SECRET');

        $response = Http::asForm()->post('https://zoom.us/oauth/token', [
            'grant_type' => 'account_credentials',
            'account_id' => env('ZOOM_ACCOUNT_ID'),
            'client_id' => $clientId,
            'client_secret' => $clientSecret,
        ]);

        if ($response->successful()) {
            Log::info('Access Token' . '' . $response->json()['access_token']);
            return $response->json()['access_token'];
        }

        throw new \Exception('Failed to retrieve Zoom access token');
    }
    public function createMeeting(Request $request)
    {
        $accessToken = $this->getZoomAccessToken();

        $startTime = now()->utc()->toIso8601String();

        $duration = 60;

        $response = Http::withHeaders([
            'Authorization' => 'Bearer ' . $accessToken,
            'Content-Type' => 'application/json',
        ])->post('https://api.zoom.us/v2/users/me/meetings', [
            'topic' => $request->topic,
            'type' => 2, // Scheduled meeting
            'start_time' => $startTime,
            'duration' => $duration,
            'settings' => [
                'join_before_host' => true,
                'mute_upon_entry' => true,
                'waiting_room' => false,
                'endMeetingOnHostLeave' => true
            ],
        ]);

        if ($response->successful()) {
            Log::info('meeting creation successful', ['data'=>$response->json()]);
            $meetingNumber = $response->json()['id'];
            Log::info('meeting creation ID', ['data'=>$meetingNumber]);
            session()->put('meetingNumber', $meetingNumber);
            return response()->json($response->json());
        }

        return response()->json(['error' => 'Failed to create meeting', 'details' => $response->json()], 400);
    }

@dossoufico do use the credentials from the development tab.
In addition, in your embed page, make sure that Meeting SDK toggle button is enabled.

If this still does not work, give me a sample of your generated token here.

Thank you so much! And sorry for late reply! I didn’t know we have to enable the meeting SDK button, I missed that part. I will try, let you know and share a sample token if it doesn’t work. Again thank you so much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.