Overview
PSFalcon uses OAuth2 authentication to securely connect to CrowdStrike Falcon APIs. Your credentials and access tokens are cached for automatic re-use, and tokens are automatically refreshed when they approach expiration.Requesting an Access Token
UseRequest-FalconToken to authenticate with the Falcon APIs:
Cloud Regions
PSFalcon supports all CrowdStrike cloud regions. Use the-Cloud parameter for automatic hostname resolution:
Available Cloud Regions
Available Cloud Regions
| Cloud Value | Hostname | Description |
|---|---|---|
us-1 | https://api.crowdstrike.com | US Commercial 1 (default) |
us-2 | https://api.us-2.crowdstrike.com | US Commercial 2 |
eu-1 | https://api.eu-1.crowdstrike.com | European Union |
us-gov-1 | https://api.laggar.gcw.crowdstrike.com | US GovCloud 1 |
us-gov-2 | https://api.us-gov-2.crowdstrike.mil | US GovCloud 2 |
If you don’t specify a cloud region, PSFalcon defaults to
us-1. The module automatically follows redirects if you connect to the wrong region.Authentication Parameters
TheRequest-FalconToken function accepts the following parameters from source code /home/daytona/workspace/source/public/oauth2.ps1:32-74:
ClientId (Required)
Your OAuth2 client identifier. Must be a 32-character hexadecimal string matching pattern
^[a-fA-F0-9]{32}$.If not provided, you’ll be prompted to enter it interactively.ClientSecret (Required)
Your OAuth2 client secret. Must be a 40-character alphanumeric string matching pattern
^\w{40}$.If not provided, you’ll be prompted to enter it interactively.Cloud (Optional)
CrowdStrike cloud region:
us-1, us-2, eu-1, us-gov-1, or us-gov-2.Defaults to us-1 if not specified.Credential Caching
PSFalcon automatically caches your credentials and token in the$Script:Falcon variable:
Automatic Token Refresh
From/home/daytona/workspace/source/public/oauth2.ps1:8-10 and oauth2.ps1:208:
- Access tokens are valid for a specific duration (typically 30 minutes)
- PSFalcon automatically checks token expiration before each API request
- If the token expires in less than 240 seconds (4 minutes), a new token is automatically requested
- You don’t need to manually refresh tokens
Checking Token Status
UseTest-FalconToken to check your current authentication status:
Token property indicates whether you have a valid, non-expired access token.
Viewing Your Token
Display the raw OAuth2 access token value:The access token is sensitive. Avoid logging or exposing it in scripts.
Revoking Tokens
Always revoke your token when you’re done to follow security best practices:Complete Script Example
Revoke-FalconToken clears cached credentials and revokes the active token with the API.
Flight Control (Multi-CID)
When working with Falcon Flight Control, use the-MemberCid parameter to authenticate to specific child CIDs:
Advanced: Custom URLs
For troubleshooting or testing, you can specify a custom API URL:Automatic Region Redirect
From/home/daytona/workspace/source/public/oauth2.ps1:181-193:
PSFalcon automatically detects and follows region redirects:
Error Handling
Handle authentication errors gracefully:Best Practices
Store Credentials Securely
Never hardcode credentials in scripts. Use environment variables, secure credential storage, or prompt for input:
Related Commands
Request-FalconToken- Request an OAuth2 access tokenTest-FalconToken- Check token statusShow-FalconToken- Display token valueRevoke-FalconToken- Revoke and clear cached credentials
Next Steps
Error Handling
Learn how PSFalcon handles API errors and response validation
Pagination
Understand automatic pagination for large result sets