"Error forwarding auth" when handling oauth flow for ChatGPT plugin

When my OAuth /authorize step redirects back into ChatGPT, it includes the code and state params (code is populated, state is not)

Then the browser makes a GET request to a URL like https://chat.openai.com/backend-api/aip/p/plugin-$MY_PLUGIN_ID/user-settings/oauth/callback?code=$THE_CODE&redirect_uri=https%3A%2F%2Fchat.openai.com%2Faip%2Fplugin-$MY_PLUGIN_ID%2Foauth%2Fcallback

This in turn returns an error like:

{"detail":"Error forwarding auth: {\"message\":\"Missing access_token\"}"}

Then the browser redirects into a URL like https://chat.openai.com/_next/data/$SOME_LONG_STRING/index.json?model=text-davinci-002-plugins&loginAip=plugin-$MY_PLUGIN_ID&loginSuccess=false

My guess is that it’s making a server-to-server request during that https://chat.openai.com/backend-api... request and that something is going wrong on your end, perhaps getting a malformed request from our /token endpoint.

Here’s my oauth settings:

	"auth": {
		"type": "oauth",
		"client_url": "https://my-server.com/oauth2/authorize",
		"scope": "global",
		"authorization_url": "https://my-server.com/oauth2/token",
		"authorization_content_type": "content-type: application/json",
		"verification_tokens": {
			"openai": "$MY_APP_VERIFICATION_TOKEN"
		}
	},

Are there other valid values of authorization_content_type I could try?

Thanks for any help you can provide.

Dan

1 Like

It turns out that the problem was that I was returning the wrong contact type from the token in point, it was expecting a multipart form encoding, and I was sending a JSON encoding

May be you can try "application/x-www-form-urlencoded" according to this related topic: https:// community .openai.com/t/oauth-token-request-failures-msal/211344