# Bug OP-15305 - Invalid refresh tokens of Nextcloud are not handled correctly 

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-15305

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 14.3.0 |
| Observed in versions | 14.1.0 |
| Sprint | 14.3.0 |
| Backlog bucket |  |
| Bug found in version (deprecated) | 14.1.x |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable | Eric Schubert |
| Product manager |  |
| Developers | OP Dev Titan Team |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Steps to reproduce

1.  Successfully configure a Nextcloud storage
    
2.  Go through the OAuth flow in OpenProject to connect a user to the Nextcloud instance
    
3.  Modifying the **token** and the **refresh token** directly in the OpenProject DB - simulating the event when the token and refresh token would be invalid on Nextcloud
    
    1.  Alternatively wait till the refresh token expires.
        
4.  Open the Files tab on a WP with the Nextcloud storage
    
5.  Observe in OpenProject a `HTTPX Timeout error` or `OAuth2 reported an error`.
    

### What is the buggy behavior?

*   The invalid refresh token does not get removed
    

### What is the expected behavior?

1.  A invalid refresh token gets removed and the OAuth flow
    
2.  The user can preform the OAuth flow again to renew the OAuth token to Nextcloud
    

###   

### Screenshots and other files

<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/111191/content">

### Additional infos

Basically what happens is this (Marcello):

1.  token gets screwed somehow
    
2.  We do a couple of requests using it, that fail.
    
3.  We try to renew the token, which also fails with a 400/429
    
4.  NC bruteforce protection kicks in and starts to throttle the responses
    
5.  After a couple of tries the delay becomes longer than our 3 second timeout window.
    
6.  We show the 500 timeout error.
    

\=&gt; We will need to handle the timeout error (and the 400/429).
