🔍 Code Extractor

class SharingLinkAccessRequest

Maturity: 48

A data class representing extended values required for requesting access to SharePoint objects exposed through tokenized sharing links, including password and access persistence options.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/links/access_request.py
Lines:
4 - 25
Complexity:
simple

Purpose

This class encapsulates the parameters needed when making requests to access SharePoint resources protected by tokenized sharing links. It handles two key scenarios: (1) providing password authentication for password-protected links, and (2) requesting perpetual access to the shared resource. The class inherits from ClientValue, making it compatible with SharePoint's client-side object model for serialization and transmission to SharePoint services.

Source Code

class SharingLinkAccessRequest(ClientValue):
    """Represents extended values to include in a request for access to an object exposed through a tokenized
    sharing link."""

    def __init__(self, ensure_access=None, password=None):
        """
        :param str password: This value contains the password to be supplied to a tokenized sharing link for validation.
             This value is only needed if the link requires a password before granting access and the calling user
             does not currently have perpetual access through the tokenized sharing link.
             This value MUST be set to the correct password for the tokenized sharing link for the access granting
             operation to succeed. If the tokenized sharing link does not require a password or the calling user
             already has perpetual access through the tokenized sharing link, this value will be ignored.
        :param bool ensure_access: Indicates if the request to the tokenized sharing link grants perpetual access to
            the calling user.
        """
        super(SharingLinkAccessRequest, self).__init__()
        self.ensureAccess = ensure_access
        self.password = password

    @property
    def entity_type_name(self):
        return "SP.Sharing.SharingLinkAccessRequest"

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

ensure_access: A boolean flag indicating whether the request should grant perpetual (ongoing) access to the calling user through the tokenized sharing link. When set to True, the user will maintain access beyond the current session. When False or None, access may be temporary. This parameter is optional and defaults to None.

password: A string containing the password required to validate access to a password-protected tokenized sharing link. This is only necessary when: (1) the link requires password authentication, and (2) the calling user does not already have perpetual access. If the link is not password-protected or the user already has perpetual access, this value is ignored. Must match the exact password configured for the sharing link. This parameter is optional and defaults to None.

Return Value

Instantiation returns a SharingLinkAccessRequest object that can be used in SharePoint API calls. The object contains two instance attributes (ensureAccess and password) and inherits serialization capabilities from ClientValue. The entity_type_name property returns the string 'SP.Sharing.SharingLinkAccessRequest', which identifies the object type in SharePoint's client object model.

Class Interface

Methods

__init__(self, ensure_access=None, password=None)

Purpose: Initializes a new SharingLinkAccessRequest instance with optional password and access persistence settings

Parameters:

  • ensure_access: Boolean flag to request perpetual access (True) or temporary access (False/None). Optional, defaults to None.
  • password: String containing the password for password-protected sharing links. Optional, defaults to None.

Returns: None (constructor)

@property entity_type_name(self) -> str property

Purpose: Returns the SharePoint entity type identifier for this class, used for serialization in the client object model

Returns: String 'SP.Sharing.SharingLinkAccessRequest' identifying the SharePoint entity type

Attributes

Name Type Description Scope
ensureAccess bool or None Stores the ensure_access parameter value indicating whether perpetual access should be granted to the calling user instance
password str or None Stores the password string required for accessing password-protected tokenized sharing links instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_value import ClientValue

Usage Example

from office365.runtime.client_value import ClientValue
from office365.sharepoint.sharing.link_access_request import SharingLinkAccessRequest

# Example 1: Request access with password
access_request = SharingLinkAccessRequest(
    password='SecurePassword123',
    ensure_access=True
)

# Example 2: Request access without password (for non-protected links)
access_request = SharingLinkAccessRequest(
    ensure_access=True
)

# Example 3: Temporary access with password
access_request = SharingLinkAccessRequest(
    password='SecurePassword123',
    ensure_access=False
)

# Access the entity type name
print(access_request.entity_type_name)  # Output: SP.Sharing.SharingLinkAccessRequest

# Access instance attributes
print(access_request.ensureAccess)  # Output: True/False/None
print(access_request.password)  # Output: password string or None

Best Practices

  • Always set ensure_access=True if you need persistent access to the shared resource beyond the current session
  • Only provide a password when the sharing link is known to be password-protected; unnecessary passwords are ignored but may indicate configuration issues
  • Store passwords securely and never hardcode them in source code; use environment variables or secure configuration management
  • This class is typically used as a parameter object for SharePoint API methods that handle sharing link access, not as a standalone component
  • The class is immutable after instantiation; create a new instance if different parameters are needed
  • Verify that the password matches the sharing link's requirements before making the request to avoid authentication failures
  • The entity_type_name property is used internally by the SharePoint client library for serialization and should not be modified

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class ShareLinkRequest 86.8% similar

    A data class representing a request for retrieving or creating a tokenized sharing link in SharePoint, encapsulating all necessary parameters for link configuration.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/links/share_request.py
  • class SharingLinkAbilities 80.8% similar

    A data class representing the set of capabilities for tokenized sharing links in SharePoint, indicating which sharing operations are enabled or disabled for the current user.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/link_abilities.py
  • class ShareLinkResponse 78.7% similar

    A response class that encapsulates information about a tokenized sharing link in SharePoint, including its retrieval or creation/update status.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/links/share_response.py
  • class SharingAbilities 78.6% similar

    Represents the matrix of possible sharing abilities for direct sharing and tokenized sharing links along with the state of each capability for the current user in SharePoint.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/abilities.py
  • class LinkInvitation 74.3% similar

    A data class representing an invitation to a tokenized SharePoint sharing link, tracking who was invited, by whom, and when.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/sharing/invitation/link.py
← Back to Browse