Hello team! I have configured an Outbound app for ...
# ask-a-descoper
s
Hello team! I have configured an Outbound app for Notion that uses DCR to connect to their MCP. Recently our users have complained that the connection "simply disappears" Looking at the tokens section, I see several error logs from trying to refresh the token. What might be the issue here? Thank you in advance for your help 🙏
n
Hello Sebastião, Currently taking a look into this issue. It looks like the token you stored for the user either expired, was revoked at the provider, or you’re fetching the wrong variant (scopes don’t match), so refresh attempts fail and the connection appears to “vanish.” We recommend using fetch latest for the user/tenant instead of “fetch with scopes” unless you’re 100% sure of the exact scopes used at connect time; otherwise, you’ll get
404 Token not found
. You can also set
forceRefresh:true
to have Descope refresh on your behalf.
s
Hey Nick, thank you for taking a look! This is an Outbound app using DCR. I'm not passing any scopes whastoever. Neither in the Outbound app definition as you can see nor at runtime when fetching the token
n
Got it. Do you by chance have
forceRefresh
set for this app? That should resolve the issue with token expiration/connection vanishing.
s
How do I set that at the app level? Or is it at runtime when requesting the token?
n
Yes,
forceRefresh
is set at runtime when you fetch the outbound token. There isn’t an app-level toggle.
s
👌 I'll do that for the Notion app specifically, but if feels like patching a deeper issue if it works
Could there be a reason for this to be happening?
n
I will conduct a further investigation on our end to figure out if a deeper issue is at play and bring it to the attention of our internal teams to explore possible ways to ensure refresh tokens are issued accordingly for outbound apps.
🙌 1
s
Thank you very much for you support!
FYI and adding to our conversation, I just encoutered this log for a Supabase Outbound App (not DCR)
@Nick Rodriguez I keep getting it, it's blocking all usage. I am calling the token endpoint as such:
Copy code
@requires_initialization
    async def get_outbound_token(self, app_id: str, descope_internal_entity_id: str, scopes: list[str] | None = None, with_refresh_token: bool = True, force_refresh: bool = True) -> dict[str, Any] | None:
        url = "https://api.descope.com/v1/mgmt/outbound/app/user/token/latest"
        headers = {"Content-Type": "application/json", "Authorization": f"Bearer {self.project_id}:{self.management_key}"}

        payload: dict[str, Any] = {
            "appId": app_id,
            "userId": descope_internal_entity_id,
            # "scopes": scopes or [],
            "options": {"withRefreshToken": with_refresh_token, "forceRefresh": force_refresh},
        }
        try:
            async with httpx.AsyncClient() as client:
                response = await client.post(url, headers=headers, json=payload)

            if response.status_code != 200:
                logger.debug(f"Failed to get outbound token for app_id={app_id}, entity_id={descope_internal_entity_id}. Status: {response.status_code}, Response: {response.text}")
                return None

            data = response.json()
            return data["token"]
        except Exception as e:
            logger.error(f"Failed to get outbound token for app_id={app_id}, entity_id={descope_internal_entity_id}: {e}")
            return None
This was working before. It is now failing constantly. I either get: • An exception • A 500 Response You can see both in the screenshots attached
n
Let me take a look into this. Also looping in @Kevin Gao here for added insight.
🙌 1
s
I keep trying on my side, it only works the first time after a connection is created. After that, always an error is returned saying there is an issue with the refresh token (or an Exception is raised)
t
Hi @Sebastião Assunção, The error as you specified is coming from the provider. it can happen if the user revoked the access on the provider side. Does it happen for specific user/users or for all? Also maybe the refresh token is empty for some reason. You can also go to the Tokens view of the outbound app and check if there's a refresh token and if you are able to refresh it from the console.
s
Hey @Tal Aharoni Thank you for jumping in! I can assure you there was no action made on the user side as this is a "user" that is my colleague so I can confirm no manual disconnection was done. Add also, the Supabase outbound app also started showing the same problems
On Notion's side, we see an increase in the frequency of these errors (which are not the same as the Supabase ones currently) showing a
Invalid refresh token
instead of
No such refresh token
Knowing that the user is not actively revoking the access on the provider side, does this make you believe the error is on the provider side itself "loosing" the connections?
t
And when you are trying to manually refresh from the console does it work?
s
The ones that show a
404
error on Descope also get an error in the console. The refresh token is in fact not found on the provider's side which would imply either: • Provider error in somehow "forgetting" the refresh token • Descope error in not storing the tokens correctly (seems weird to have started an error like this "out of nowhere") • My user's manually revoking on the provider's side (which I know to not be True, but must be considered) Regarding the
notion-mcp
outbound app, it is implemented using DCR with the token endpoint being
https://mcp.notion.com/token
to which I cannot find the correct documentation to test it's refresh token endpoint
Another finding that might help get to the root cause: I just ran a test where I had 1 connection on Descope for the Supabase app with no
Refres Error
entries. This is my own connection so I am 100% sure I did not touch it over the weekend and I know for a fact it was working on Friday. I used that access token to connect to Supabase's MCP and got
401 Unauthorized
. I tried refreshing the token via the dashboard by clicking on Refresh Access Token but nothing happened: no feedback, no error, no refresh: the same token was there. I deleted the connection and went through the entire flow again: 1. Starting on my app, made a call to
https://api.descope.com/v1/outbound/oauth/connect
2. On my app, went through the OAuth flow as normal 3. New token record appears (associated with the same User as before (confirming it is my account) 4. Now the token works! Something happened over the weekend without me touching anything on the provider's side. I did not even touch the computed between Friday and today
t
1. for the
404
error, you can get the refresh token from Descope and try refreshing it manually with the provider's
/token
endpoint do make sure it's something in the provider side. 2. regarding MCP with dynamic registration (DCR) the providers mostly use different endpoints and have different constrains. also the client is non-confidential and in many cases refresh are not supported or requires additional actions. 3. for the refresh that didn't do anything and didn't raise error, do you have cf-ray of the request or specific time and project ID so i can check it deeper?
s
Regarding (1) -> I can confirm that the refresh token is in fact invalid on the provider's
/token
endpoint. My issue is that I do not have the slightest hint of why the refresh token stopped being valid when I know that on Friday it was working and on Monday it is not without any actions performed on my side. It seems it would either be a provider error or somehow the tokens not being correctly managed by Descope over time. Considering I've seen this happen to Notion and Supabase outbound apps in recent times, it points to some defect in the
Descope <-> Provider
connection Regarding (2) -> Yes, DCR means different endpoints. I'm not being able to find the Notion MCP documentation on DCR to be able to test any refresh token directly so I cannot provide much more info on this topic Regarding (3) -> I am sorry, I did not keep the cf-ray ID and I have since (as mentioned) deleted the connection and created a new one that is working correctly. It seems like creating fresh connections always fixes the issue (until the refresh inevitably fails). I will be sure to keep
cf-ray
IDs going forward to facilitate your side of things 🙏
t
Regarding(1) - did it happen only in DCR apps? If refreshing manually also failed it indicates that the problem is probably not on Descope side. we didn't get such complaints from other customers but we will try reproducing it here as.
s
No, I also had it with the Supabase app. You can see it in this message above here: https://authtown.slack.com/archives/C04490U8M7A/p1763375546513999?thread_ts=1762972327.996989&cid=C04490U8M7A
For example, I currently have a user (with Descope ID
U2yaXD9LWDZCdd42Q0AzBpKMQ8VE
) that is not able is in this state in the Supabase app. This happened over the weekend without ANY action on the user's side. How can I handle this on the application side?
The user connected last week, it all was working normally. Then Descope got this error at some point when trying to refresh and it's preventing the user from using the connection with no way of refreshing the token
t
Thanks i'll try to check it deeper for that case. If you have additional user that same happened to him please share as well.
s
I will! I'm sorry for not having more specific ID and request CF-Rays
I'll save more information as this error persists over time
t
That's fine. I'm trying to get to the point it stopped working and see if anything special happened there.
s
Since the user
U2yaXD9LWDZCdd42Q0AzBpKMQ8VE
is my co-worker, I can perform actions on it. I have just manually deleted the connection on Descope's dashboard and re-created it from our App's side so now it is active
Hey @Tal Aharoni letting you know that this is still an ongoing error affecting production. Our users' connections get "destroyed" from Descope errors when refreshing the token from Supabase and Notion
Everytime the token refresh is attempted for the
Notion MCP
outbound app, it fails with
[E151103] Failed to refresh OAuth application token: Failed to refresh OAuth app token [error: oauth2: "invalid_grant" "Invalid refresh token"]
CF-Ray of an example:
9a2189961885c156-LIS
t
Hi @Sebastião Assunção, Thank you for the details. we were able to reproduce and identify the issue. It happens only in some cases and related only to providers that rotate their refresh token upon refresh. We are working on a fix and will update as soon as it will be ready 🙏
s
Hello @Tal Aharoni Thank you for keeping an eye on this Does this explain both Supabase and Notion? Have you found other providers that have this error?
t
Yes both of them are doing
refresh_token
rotation. (you can see that after performing token refresh the
refresh_token
changes). It can happen to every provider that performs refresh rotation (it doesn't happen all the time, but if the token got corrupted it will fail every time until connecting again)
s
That adds up. The first time after re-connecting works but stops immediately after. It's more noticeable on Notion but might very well be because I've added
forceRefresh
as per recommended above
t
Correct. forcing refresh will increase the changes for failure in this case. As i later wrote, i don't suggest to use
force_refresh
@Sebastião Assunção, issue should be resolved now. Please re-connect tokens that contains those errors already. It shouldn't happen again for new tokens. 🙌 If you still encounter the issue please let us know
s
Thank you @Tal Aharoni, legend🙏🙏 Can you shed some light on what happened? Both were related to MCP servers, wondering if that might be connected Thanks again for your help
t
Not related to MCP. It was a not so common race issue causing to keep the old
refresh_token
instead of the new one when the provider's refresh operation is also rotating the
refresh_token
with a new one. The main problem in that case is that the old
refresh_token
is not usable anymore by the provider and it will never get fixed until connecting the user again and getting new
access_token
and
refresh_token
🙌 1
s
Hello @Tal Aharoni Unfortunately, this issue is back Our users keep getting disconnected after using Notion for no apparent reason
CF Ray from a manual refresh attempt from the dashboard:
9abc76bcfcabe3d1-LIS
t
Hi @Sebastião Assunção, This token was created at
November 13th
and probably got corrupted before the fix was deployed at
November 23th
As i wrote above, the fix is relevant only for new tokens that didn't get corrupted yet. I suggest to delete those tokens and re-connect the users again to get new token.
s
@Tal Aharoni I'm sorry for picking out a wrong example. However, this is something that is still ongoing. I have just cleanup all old tokens around 2hr ago and came back now to see yet another corrupted token CF Ray:
9abdc7523e71785f-LIS
t
Hey @Sebastião Assunção, How did you cleaned them up? i still see this token is from
November 13th
s
@Tal Aharoni I've just deleted all tokens that had a
Last Refresh Error
and refreshed them all exactly now. I'll keep monitoring and see if any of them yield the same error in the future 🙏
t
Ok, thanks for the update 🙌
s
Hello @Tal Aharoni I just got another one of those errors. It happened on my own account. I then tried to go on the dashboard and refresh it manually and got the error as well CF Ray:
9ac45a6e7cf5e3d1-LIS
👀 1
t
Hey @Sebastião Assunção, We are checking that. Meanwhile i see that you are passing
force_refresh=true
and
with_refresh_token=true
, any special reason for that? Descope is refreshing automatically when needed. when forcing to refresh it increases the time it takes to get each token.
s
Hey @Tal Aharoni Thank you for being on top of this. I started doing that in the hopes of fixing this exact issue as per @Nick Rodriguez's recommendation above in this thread
t
Also, if you don't use the
refresh_token
in your services it also recommended not to ask
with_refresh_token
to avoid transferring sensitive data without need
Yes, this recommendation was before getting to the root cause and tried to get immediate solution. Currently i suggest to avoid using that
s
Yessir! Making those changes as we speak
t
Cool 👍 Also i see that you perform multiple concurrent requests (sometimes 4 same requests at the exact same time). any reason for that?
s
Locally we have caching turned off which results in more requests than wanted
Hey @Tal Aharoni Any updates or insights into this issue?
t
Hey @Sebastião Assunção, From the investigation in this case, it seems like we got invalid token from Notion. It seems related to the concurrent requests due to the
force_refresh
param. In any case we will if we can add additional protections also for such issues. Did you implement the suggested changes above? it should significantly reduce and probably eliminate the chances for it to happen.
s
Yes, I've implemented the changes as mentioned above I'll keep you posted then if the issue resurfaces Again, many thanks for your support here
🙌 1
Hello @Tal Aharoni Sorry for bothering again but the issue appeared again for one of our users. I have gone and tried refreshing the token manually on Descope and got the "Invalid refresh token" error. CF Ray:
9b20ed6f5fec4898-LIS
Good afternoon @Tal Aharoni Unfortunately, this is now happening on other Outbound apps like Hubspot. See attached screenshot CF-Ray of a manual attempt to refresh a Hubspot token:
9b28abee7852055d-LIS
t
Hi @Sebastião Assunção , Thank you for the update. We will check that and keep you updated 🙏
s
Thank you very much @Tal Aharoni
t
Hi @Sebastião Assunção, Regarding the hubspot token, it seems to be from November 13th so it might be corrupted before the fix was deployed. From what i read, another option is that refresh token was revoked. it can happed from different reasons:
Copy code
-Uninstalling the app from the HubSpot portal
-Manually revoking access in account settings
-Admin removing the app from the organization
In this case we can't know from the caller side what is the real reason. Does it happen to specific users? all users? are you the owner of that OAuth app?
Other reasons can be scopes changes in the app or some limits on the app side
Also, i still see that you perform multiple (2-3) requests for the same user and app at the exact same time that is not recommended. When fetching new token fails, you should mark the connection on your side as one the requires re-authnetication from the user
s
Hello @Tal Aharoni
Does it happen to specific users? all users?
No, it seems that once it fails for one, it starts failing more frequently for others Here are CF-Rays from attempts to refresh tokens from 4 different users. Some of which (as you can see from the screenshot) have access token expiration dates as late as today (Dec 29th)
9b590654fb9b21da-LIS
9b5906b6ca2721da-LIS
9b5906ebb96021da-LIS
9b59071eedd721da-LIS
Are you the owner of that OAuth app?
Yes, I am and we have changed nothing ever since it was created Regarding our inefficiencies, I'll look into our BE flows and evaluate how we can reduce the number of requests though I fail to see how that could impact the token refresh errors Thank you bey much for your help
Hello @Tal Aharoni We just had a User complaining that the connection dropped again for their Hubspot integration. I asked the user to delete the connection and try again to connect. The connection was successful and the token appeared in the console around 16;16h. The Associated User ID is
U333j66Ag7xIVrTGR77zajf69RUC
I then tried almost immediately after to refresh the token from the dashboard (manually) and got a 400. CF-Ray for that request is
9b5a9f4ad9bac534-LIS
This token was obtained correctly less than 5 minutes before with the connection being successful...
t
Hey @Sebastião Assunção, Thank you for all the details and sorry for the inconvenient. We are checking it
Hi @Sebastião Assunção, From investigating the logs we were not able find an issue in Descope. It seems that the refresh token was invalid from the beginning and therefore failed to forceRefresh (and later on failed to refresh when the access token got expired). We've also were not able to reproduce the issue without uninstalling the app from the user side (then the refresh token became invalid and we got the same experience) To continue the investigation we will add internal logging to make sure we didn't miss anything on Descope. I can also suggest that you can contact Hubspot support with the relevant error correlationID
2c62c1bf-b8c6-439f-b3a1-530e2daedb9c
and maybe they can shed some light on why this refresh token is invalid. Also, do you still see issues in other providers (other than hubspot)?
s
Hey @Tal Aharoni Thank you very much for your help So you were able to connect to the Hubspot App I have setup on the Outbound app with a valid refresh token and were able to refresh it a few times? Regarding the correlation ID you sent, just so we're on the same page, that is the ID of a request for refreshing the token that failed? We've also been having issues with the
notion-mcp
outbound app quite a few times. Here are 2 CF-RAYs from refresh requests of tokens that have
Access Token Expiration
on December 23rd:
9b60e94328d9c640-LIS
9b60e98e7ef6c640-LIS
t
No, we created a setup of our own. We don't have access to use your account. Yes the correlation ID is of the request you did ~5 minutes after the user connected. CF ray
9b5a9f4ad9bac534
. I still see concurrent requests for the same user. Is it something you are planning to handle?
if you agree, i can signUp from your console and connect to hubspot there as a user.
s
Yes, we're planning to address that issue. You see ~3 IDENTICAL requests at the same time? To retrieve the access token for user X and app A? Yes, I agree! It would be ideal to get the same conditions to try to isolate the issue 🙏