# App restarts on macOS during in-client OAuth flow

**URL:** <https://devforum.zoom.us/t/app-restarts-on-macos-during-in-client-oauth-flow/113340>\
**Category:** Zoom Apps\
**Tags:** sdk\
**Created:** [July 10, 2024, 12:53am UTC](https://devforum.zoom.us/t/app-restarts-on-macos-during-in-client-oauth-flow/113340 "2024-07-10T00:53:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fbari](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/fbari/32/61336_2.png) [@fbari](https://devforum.zoom.us/u/fbari)\
**Post date:** [July 10, 2024, 12:53am UTC](https://devforum.zoom.us/t/app-restarts-on-macos-during-in-client-oauth-flow/113340/1 "2024-07-10T00:53:28Z")

</div>

Hello,

I’m having an issue with the Zoom SDK on macOS desktop client. During the in-client OAuth authorization process, specifically after clicking “Allow” in the OAuth prompt, the app restarts unexpectedly, which prevents the OAuth flow from completing. Additionally, clicking any other buttons in the prompt (“Decline” or “X”) causes the app to close entirely. This behavior does not occur on Windows, where the authorization completes successfully and the app stays open after the prompt.

**Issue Details:**

- **Platform** : macOS
- **SDK** : Javascript - `@zoom/appssdk` v0.16.21
- **Zoom client versions** : 6.1.1 (36333 - macOS) | 6.1.1 (41705 - Windows)
- **macOS version** : Sonoma 14.5
- **Windows 11 version** : 23H2 (22631.3810)
- **Problem** : On macOS, app restarts or closes immediately after OAuth prompt, preventing the `onAuthorized` event from triggering.
- **Expected** : The OAuth flow completes as expected without any app restarts or closing, and the `onAuthorized` event is triggered for the app to handle.

**Observed Behavior:**

- **macOS** : The app restarts or closes immediately after the OAuth prompt.
- **Windows** : The authorization completes successfully and the app stays open.

**Videos for Reference:**

Functioning app on Windows: `imgur.com/mihE9cf`

Issue on macOS: `imgur.com/9BFsY3a`

**Code to Reproduce:**

Here’s a simplified version of the code, including custom hooks used to manage the OAuth process:

**index.html**

```html
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Zoom SDK Test</title>
    </head>
    <body>
        <div id="root"></div>
    </body>
</html>

```

**index.jsx**

```js
import React, { useState, useEffect } from 'react';
import ReactDOM from 'react-dom';
import initZoomSdkAsync from 'vendor/initZoomSdkAsync';
import ZoomAuth from './ZoomAuth';

const App = () => {
    const [isSdkInitialized, setIsSdkInitialized] = useState(false);

    useEffect(() => {
        initZoomSdkAsync().then(() => {
            setIsSdkInitialized(true);
        });
    }, []);

    return (
        <div>
            <h1>Zoom Authorization Test</h1>
            {isSdkInitialized ? <ZoomAuth /> : <p>Loading...</p>}
        </div>
    );
};

ReactDOM.render(<App />, document.getElementById('root'));

```

**ZoomAuth.jsx**

```js
import React, { useState } from 'react';
import { useAuthorizeZoom } from 'useAuthorizeZoom';
import { useOnAuthorized } from 'useOnAuthorized';
import versionFile from 'version.json';

const ZoomAuth = () => {
    const handleAuthorize = useAuthorizeZoom();
    const [outputText, setOutputText] = useState('');

    useOnAuthorized((event) => {
        const eventText = JSON.stringify(event);
        console.debug('Received onAuthorized event:', eventText);
        setOutputText(eventText);
    });

    return (
        <div>
            <button onClick={handleAuthorize}>Authorize with Zoom</button>
            <p>{outputText}</p>
            <p />
            <p>App version: {versionFile.version}</p>
        </div>
    );
};

export default ZoomAuth;

```

**useAuthorizeZoom.js**

```js
import { useCallback } from 'react';
import zoomSdk from 'vendor/zoomSdk';

export const useAuthorizeZoom = () => {
    const handleAuthorize = useCallback(async () => {
        console.debug('Starting OAuth flow with Zoom.');
        try {
            const codeChallenge = 'exampleCodeChallenge123';
            const state = 'exampleState456';

            await zoomSdk
                .authorize({
                    state,
                    codeChallenge,
                })
                .then((ret) => {
                    console.debug(ret);
                })
                .catch((e) => {
                    console.error(e);
                });
        } catch (error) {
            console.error('Error initiating OAuth flow:', error);
        }
    }, []);

    return handleAuthorize;
};

export default useAuthorizeZoom;

```

**useOnAuthorized.js**

```js
import { useEffect } from 'react';
import zoomSdk from 'vendor/zoomSdk';

export const useOnAuthorized = (callback) => {
    useEffect(() => {
        zoomSdk.addEventListener('onAuthorized', callback);
    }, [callback]);
};

export default useOnAuthorized;

```

Given the difference in behavior observed between Windows and macOS, the issue appears to be a bug either with the Zoom SDK or the macOS desktop client. Could you please investigate this behavior? Any assistance or insights would be greatly appreciated.

Thank you for your attention.
