OAuth token refresh with custom GPT

I’m in the process of integrating a third-party service with a custom GPT and encountering a challenge regarding OAuth token management.

  • Initial OAuth Process: Everything works fine initially with OAuth, where after the first authentication, the access token operates as expected.

  • Issue with Token Renewal: The problem arises when the access token expires, which is normal. At this point, the system asks the user to authenticate again, which is standard. However, the issue is that after re-authentication, instead of renewing the access as it should, the system incorrectly redirects to https://chat.openai.com/undefined. This redirection suggests a problem in the automated management of the refresh token.

  • Have any of you encountered similar redirection issues after re-authenticating in your GPT-OAuth integrations?

  • Any advice on correctly managing the OAuth token refresh to prevent such redirection mishaps?

  • Are there any known fixes to ensure uninterrupted re-authentication and access token renewal?

G’day—I have refresh tokens working in my code. It was finnicky so I wrote up a guide: Guide: How OAuth refresh tokens & revocation work with GPT Actions

I can confirm that token refreshes work, and that ChatGPT will call /oauth/token with your refresh token to ask for a new access token once the initial access token has expired. From reading your post, it sounds like ChatGPT was asking the user to log in again, which it shouldn’t be doing—the token refresh process should happen automatically without user interaction. Is that what’s happening?

Are you sure that it’s a token refresh problem?

I am being pointed to that same undefined path because of a callback url changing problem? Saved CustomGPT, callback_url broke

You should have a token refresh url endpoint which should manage the token refresh whenever requested

Is there a good tutorial on how to set up a third-party service with OAuth and a custom GPT? I haven’t found one with step-by-step instructions and I keep getting stuck.

This help? https://www.youtube.com/watch?v=6HFp0ISO4XI

Thanks for the video, but that doesn’t quite match what I’m looking for. What I want is to create another end point that proxies the login to Google, so I can save state about the user in a DB.

This tutorial is closer: https://www.youtube.com/watch?v=RZ3RvoRz0hA

As is: ChatGPT Action Authentication. Create a custom GPT with an action that… | by Garun Vagidov | Jan, 2024 | AWS Tip

1 Like