microsoft / azurechat

🤖 💼 Azure Chat Solution Accelerator powered by Azure Open AI Service
MIT License
1.24k stars 1.22k forks source link

GitHub OAuth timed out #69

Closed masatatsu8 closed 1 year ago

masatatsu8 commented 1 year ago

I successfully got the app to work on a local machine directly connected to the Internet, using GitHub authentication.

Next, I tried to get the app to work on a PC connected to the company network under proxy management, using the same API and authentication settings.

But I got the following error and GitHub authentication failed.

C:\Users\me\work\azurechatgpt\src> npm run dev

> azure-open-ai-accelerator@0.1.0 dev
> next dev

- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- info Loaded env from C:\Users\me\work\azurechatgpt\src\.env.local
- warn You have enabled experimental features (serverActions, serverActionsBodySizeLimit) in next.config.js.
- warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

- event compiled client and server successfully in 392 ms (20 modules)
- wait compiling...
- event compiled client and server successfully in 426 ms (20 modules)
- wait compiling /page (client and server)...
- event compiled client and server successfully in 7.5s (2037 modules)
[next-auth][warn][EXPERIMENTAL_API]
`getServerSession` is used in a React Server Component.
https://next-auth.js.org/configuration/nextjs#getServerSession}
https://next-auth.js.org/warnings#EXPERIMENTAL_API
- wait compiling /api/auth/[...nextauth]/route (client and server)...
- event compiled client and server successfully in 476 ms (2105 modules)
[next-auth][error][OAUTH_CALLBACK_ERROR]
https://next-auth.js.org/errors#oauth_callback_error outgoing request timed out after 3500ms {
  error: RPError: outgoing request timed out after 3500ms
      at eval (webpack-internal:///(sc_server)/./node_modules/openid-client/lib/helpers/request.js:115:19)
      at async Client.grant (webpack-internal:///(sc_server)/./node_modules/openid-client/lib/client.js:1182:26)
      at async Client.oauthCallback (webpack-internal:///(sc_server)/./node_modules/openid-client/lib/client.js:520:30)
      at async oAuthCallback (webpack-internal:///(sc_server)/./node_modules/next-auth/core/lib/oauth/callback.js:120:22)
      at async Object.callback (webpack-internal:///(sc_server)/./node_modules/next-auth/core/routes/callback.js:18:79)
      at async AuthHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/core/index.js:202:38)
      at async NextAuthRouteHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:49:30)
      at async NextAuth._args$ (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:83:24)
      at async eval (webpack-internal:///(sc_server)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:249:37) {
    name: 'OAuthCallbackError',
    code: undefined
  },
  providerId: 'github',
  message: 'outgoing request timed out after 3500ms'
}
masatatsu8 commented 1 year ago

The environment variables http_proxy and https_proxy are configured in Windows system preferences and .env.local.

thivy commented 1 year ago

@masatatsu8 are you still having this issue? what is the callback url on the GitHub OAuth apps?

masatatsu8 commented 1 year ago

@thivy Yes, I still have the issue. The call back url is the following one as described in README. It worked fine on another PC.

http://localhost:3000/api/auth/callback/github

patst commented 1 year ago

we use a proxy as well in our environment and is very painful.

We had to patch the next-auth files in order to make the login work. This seems to be the desired behaviour (for whatever strange reasons), see https://next-auth.js.org/tutorials/corporate-proxy The patch files in the docs are no longer up-to-date. Better edit the files in the node_modules folder manually and create a patch out of it for automation

After being able to login behind a corporate proxy we still struggle with the call to the Azure OpenAI instance using a proxy. This seems to be done using the axios framework. So far I was not able to pass the proxy, https-agent or whatever in a way that works.

Unfortunately setting http(s)_proxy (alone) does not work. Each http client used in the application seems to expect a different proxy configuration.