🔍 Code Extractor

class SpaApplication

Maturity: 36

A class representing configuration settings for a single-page application (SPA), specifically managing redirect URIs used in OAuth/authentication flows.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/applications/spa.py
Lines:
5 - 9
Complexity:
simple

Purpose

This class encapsulates the configuration for a single-page application within the Office365 API context. It inherits from ClientValue, making it a data transfer object that can be serialized and sent to Office365 services. The primary responsibility is to manage and store redirect URIs that are used during OAuth authentication flows for SPAs. These URIs specify where users should be redirected after authentication.

Source Code

class SpaApplication(ClientValue):
    """Specifies settings for a single-page application."""

    def __init__(self, redirect_uris=None):
        self.redirectUris = StringCollection(redirect_uris)

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

redirect_uris: An optional collection of redirect URIs (URLs) that the single-page application will use for OAuth authentication callbacks. Can be None, a list of strings, or any iterable containing URI strings. These URIs must be registered with the identity provider and match exactly during authentication flows.

Return Value

Instantiation returns a SpaApplication object with a redirectUris attribute containing a StringCollection of the provided redirect URIs. The class itself doesn't have methods that return values, but the instance can be used as a ClientValue in Office365 API operations.

Class Interface

Methods

__init__(self, redirect_uris=None)

Purpose: Initializes a new SpaApplication instance with optional redirect URIs for OAuth authentication flows

Parameters:

  • redirect_uris: Optional collection of redirect URI strings. Can be None, a list, or any iterable of strings representing valid URLs

Returns: None (constructor)

Attributes

Name Type Description Scope
redirectUris StringCollection A collection of redirect URIs used for OAuth authentication callbacks. Stores the URLs where users will be redirected after authentication in the single-page application instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_value import ClientValue
from office365.runtime.types.collections import StringCollection

Usage Example

from office365.runtime.client_value import ClientValue
from office365.runtime.types.collections import StringCollection

class SpaApplication(ClientValue):
    def __init__(self, redirect_uris=None):
        self.redirectUris = StringCollection(redirect_uris)

# Create an SPA application with redirect URIs
redirect_urls = [
    'https://myapp.example.com/callback',
    'https://myapp.example.com/auth/redirect'
]
spa_app = SpaApplication(redirect_uris=redirect_urls)

# Create an SPA application without redirect URIs
spa_app_empty = SpaApplication()

# Access the redirect URIs
print(spa_app.redirectUris)

Best Practices

  • Always provide valid, registered redirect URIs that match your application's OAuth configuration
  • Redirect URIs should use HTTPS in production environments for security
  • The redirect_uris parameter accepts None, which creates an empty StringCollection
  • This class is typically used as part of larger Office365 application registration or configuration operations
  • As a ClientValue subclass, instances are meant to be serialized and sent to Office365 services, not for complex business logic
  • Do not modify the redirectUris attribute directly after instantiation; create a new instance if URIs need to change
  • Ensure redirect URIs are properly formatted URLs before passing them to the constructor

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class WebApplication 76.1% similar

    A data class that encapsulates configuration settings for a web application, including home page URL, logout URL, and redirect URIs for OAuth 2.0 authentication flows.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/applications/web.py
  • class PublicClientApplication 72.4% similar

    A configuration class that specifies settings for public client applications such as mobile apps, desktop applications, or other non-web clients that cannot securely store client secrets.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/applications/public_client.py
  • class ApiApplication 64.0% similar

    A data class representing configuration settings for an application that implements a web API, specifically for Azure AD application registration.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/applications/api.py
  • class Configuration 59.3% similar

    A configuration class that specifies additional application IDs allowed to manage and index content in an externalConnection within the Office365 environment.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/search/external/configuration.py
  • class SPACSServicePrincipalInfo 57.1% similar

    A data class representing service principal information for SharePoint Authentication and Authorization (SPACS), including application endpoint authorities and display name.

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