nextcloud / nextcloud/server

[Bug]: Unable to update token for email shares

Open
#53,442 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop 32-feedback bug feature: sharing
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
Bug description

After digging into this pull request, I found (and tested to be sure) that you can't update the token of a mail share.

TLDR: The bug is here

Steps to reproduce

[!TIP]
Checkout the OCS Share API for more info (you'll see that it's out of date)

  1. Create a link share from the GUI or through the API (POST <hostname>/ocs/v2.php/apps/files_sharing/api/v1/shares) (shareType = 3)
  2. Update the token through the GUI or API (PUT <hostname>/ocs/v2.php/apps/files_sharing/api/v1/shares/<shareID>)
  3. It works.

Now if we do the same with mail shares:

  1. Create a link share from the GUI or through the API (POST <hostname>/ocs/v2.php/apps/files_sharing/api/v1/shares) (shareType = 4)
  2. Update the token through the GUI or API (PUT <hostname>/ocs/v2.php/apps/files_sharing/api/v1/shares/<shareID>)
  3. Now it's more subtle, because the server returns that the token have been updated:
<?xml version="1.0"?>
<ocs>
 <meta>
  <status>ok</status>
  <statuscode>200</statuscode>
  <message>OK</message>
 </meta>
 <data>
  <id>1</id>
  <share_type>4</share_type>
  ...
  <token>cust0mTok3n</token>
  ...
 </data>
</ocs>
  1. But now just request data about the share through GUI or API (GET <hostname>/ocs/v2.php/apps/files_sharing/api/v1/shares/<shareID>), and you'll find out that the token is still the original one
Expected behavior

Sharing with mail should offer the ability to edit the token, just like how sharing with link works.
Everything is ready to do that, but in practice, the server does not care about the provided token

Nextcloud Server version

master

Operating system

None

PHP engine version

None

Web server

None

Database engine version

None

Is this bug present after an update or on a fresh install?

None

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report

List of activated Apps

Nextcloud Signing status

Nextcloud Logs

Additional info

I haven't filled in the details of my installation because I provided you with the location of the bug in the 'master' branch (as of 11 June 2025), so I don't think it would be helpful to provide any more information.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps/sharebymail/lib/ShareByMailProvider.php around lines 740-758, then reproduce the OCS API flow by creating a mail share, updating its token, and fetching the share again. Done means the updated token is persisted and returned consistently for mail shares, as it is for link shares.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.