class CredentialType
An enumeration-style class that defines constants representing different types of authentication credentials.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/runtime/auth/credential_type.py
1 - 8
simple
Purpose
This class serves as a namespace for credential type constants used in authentication systems. It provides integer identifiers for different authentication methods including None (no authentication), Basic authentication, NTLM authentication, and SAML authentication. This pattern is commonly used for type-safe credential type identification in authentication workflows.
Source Code
class CredentialType:
def __init__(self):
pass
None_ = 0
Basic = 1
Ntlm = 2
Saml = 3
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
- | - |
Parameter Details
__init__: The constructor takes no parameters and performs no initialization. It exists only to allow instantiation of the class, though the class is primarily intended to be used for its class-level constants rather than instantiation.
Return Value
Instantiation returns a CredentialType object with no instance-specific state. The primary value of this class comes from accessing its class-level integer constants (None_, Basic, Ntlm, Saml) rather than from instantiated objects.
Class Interface
Methods
__init__(self)
Purpose: Initializes a CredentialType instance with no state
Returns: None - constructor returns the instance implicitly
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
None_ |
int | Represents no authentication (value: 0). Uses underscore suffix to avoid conflict with Python's None keyword. | class |
Basic |
int | Represents Basic authentication method (value: 1). Used for username/password authentication schemes. | class |
Ntlm |
int | Represents NTLM (NT LAN Manager) authentication method (value: 2). Used for Windows-based authentication. | class |
Saml |
int | Represents SAML (Security Assertion Markup Language) authentication method (value: 3). Used for single sign-on (SSO) scenarios. | class |
Usage Example
# Access credential type constants directly from the class
from credential_module import CredentialType
# Use constants without instantiation (recommended)
if auth_type == CredentialType.Basic:
print("Using Basic authentication")
elif auth_type == CredentialType.Ntlm:
print("Using NTLM authentication")
elif auth_type == CredentialType.Saml:
print("Using SAML authentication")
else:
print("No authentication")
# Store credential type
current_auth = CredentialType.Basic
# Compare credential types
def authenticate(credential_type):
if credential_type == CredentialType.None_:
return "No authentication required"
elif credential_type == CredentialType.Basic:
return "Perform basic auth"
elif credential_type == CredentialType.Ntlm:
return "Perform NTLM auth"
elif credential_type == CredentialType.Saml:
return "Perform SAML auth"
result = authenticate(CredentialType.Saml)
Best Practices
- Access the class constants directly without instantiating the class (e.g., CredentialType.Basic)
- Use these constants for type-safe credential type comparisons rather than magic numbers
- Consider using Python's enum.Enum or enum.IntEnum for more robust enumeration behavior in modern code
- The None_ constant uses an underscore suffix to avoid conflict with Python's None keyword
- These constants are immutable class variables and should not be modified at runtime
- This pattern is a legacy approach; modern Python code should prefer enum.IntEnum for better type safety and IDE support
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class UserCredential 65.6% similar
-
class NetworkCredentialProvider 60.2% similar
-
class AttachmentType 56.9% similar
-
class PasswordCredential 55.7% similar
-
class ClientCredential 55.2% similar