🔍 Code Extractor

class UserConsentRequest

Maturity: 48

Represents a user consent request for accessing an app or granting permissions when admin authorization is required in an admin consent workflow.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/identitygovernance/userconsent/request.py
Lines:
4 - 12
Complexity:
moderate

Purpose

This class models the details of a consent request created by a user when they need admin approval to access an application or grant permissions. It encapsulates information such as the justification for access, the current status of the request, and approval details. This is part of the Microsoft Graph API integration for managing admin consent workflows in Office 365 environments.

Source Code

class UserConsentRequest(Entity):
    """
    Represents the details of the consent request a user creates when they request to access an app or to grant
    permissions to an app. The details include justification for requesting access, the status of the request,
    and the approval details.

    The user can create a consent request when an app or a permission requires admin authorization and only when the
    admin consent workflow is enabled.
    """

Parameters

Name Type Default Kind
bases Entity -

Parameter Details

bases: Inherits from Entity class, which provides base functionality for Office 365 entities including property management, serialization, and API interaction capabilities

Return Value

Instantiation returns a UserConsentRequest object that represents a consent request entity. The object provides access to consent request properties and methods inherited from the Entity base class for interacting with the Microsoft Graph API.

Class Interface

Methods

__init__()

Purpose: Initializes a new UserConsentRequest instance, inheriting from Entity base class

Returns: A new UserConsentRequest object

Attributes

Name Type Description Scope
justification string The user's justification for requesting access to the app or permissions instance
status string The current status of the consent request (e.g., pending, approved, denied) instance
approval_details object Details about the approval decision including approver information and timestamp instance
app_id string The identifier of the application for which consent is being requested instance
pending_scopes array List of permission scopes that are pending approval instance

Dependencies

  • office365

Required Imports

from office365.entity import Entity
from office365.directory.userconsentrequest import UserConsentRequest

Usage Example

from office365.directory.userconsentrequest import UserConsentRequest
from office365.graph_client import GraphClient

# Initialize Graph client with credentials
client = GraphClient.with_client_secret(tenant_id, client_id, client_secret)

# Get a specific consent request
consent_request = client.identity_governance.app_consent.user_consent_requests.get_by_id('request_id')
consent_request.get().execute_query()

# Access properties (inherited from Entity)
print(f"Status: {consent_request.properties.get('status')}")
print(f"Justification: {consent_request.properties.get('justification')}")

# Create a new consent request
new_request = UserConsentRequest()
new_request.set_property('justification', 'Need access for business purposes')
client.identity_governance.app_consent.user_consent_requests.add(new_request).execute_query()

Best Practices

  • Always ensure the admin consent workflow is enabled in the tenant before creating consent requests
  • Provide clear and detailed justification when creating consent requests to help admins make informed decisions
  • Use the inherited Entity methods for property access and modification rather than direct attribute manipulation
  • Execute queries using execute_query() method after making API calls to ensure data is fetched or persisted
  • Handle authentication properly by initializing the GraphClient with appropriate credentials before working with consent requests
  • Check the status property to determine if a consent request has been approved, denied, or is pending
  • Be aware that this class is part of the identity governance namespace and requires appropriate API permissions

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class AppConsentRequest 90.7% similar

    Represents a user's request to a tenant admin for consent to access an app or grant permissions to an app, used in Microsoft Graph API identity governance workflows.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/identitygovernance/appconsent/request.py
  • class UserConsentRequestCollection 80.4% similar

    A collection class for managing UserConsentRequest entities, providing methods to query, retrieve, and manipulate multiple user consent requests within the Microsoft Graph API context.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/identitygovernance/userconsent/request_collection.py
  • class AppConsentRequestCollection 76.2% similar

    A collection class for managing AppConsentRequest objects, providing methods to query and filter app consent requests within Microsoft Graph API.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/identitygovernance/appconsent/request_collection.py
  • class AppConsentApprovalRoute 72.0% similar

    A container class that provides access to app consent request API resources, specifically exposing a collection of app consent requests where admin consent has been requested by users.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/identitygovernance/appconsent/approval_route.py
  • class AgreementAcceptance 60.3% similar

    Represents the current status of a user's response to a company's customizable terms of use agreement powered by Azure Active Directory (Azure AD).

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/identitygovernance/termsofuse/agreement_acceptance.py
← Back to Browse