class UserConsentRequest
Represents a user consent request for accessing an app or granting permissions when admin authorization is required in an admin consent workflow.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/identitygovernance/userconsent/request.py
4 - 12
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
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class AppConsentRequest 90.7% similar
-
class UserConsentRequestCollection 80.4% similar
-
class AppConsentRequestCollection 76.2% similar
-
class AppConsentApprovalRoute 72.0% similar
-
class AgreementAcceptance 60.3% similar