# OAuth2 Refresh Token Detector
# Detects refresh tokens in OAuth2 responses for token renewal
# Example: {"access_token": "...", "refresh_token": "8xLOxBtZp8...", ...}
#
# Refresh tokens are used to obtain new access tokens when they expire
# This detector creates a separate user variable for the refresh token
#
# Created: December 2024
# Author: Web Performance Inc

# Detector type: Sticky Regular Expression Assignment Detector

# Human-readable name for ASM UI
detector.name=OAuth2 Refresh Token (JSON)

# Pattern to extract refresh_token from JSON responses
# Refresh tokens are typically longer and may contain more varied characters
search.pattern="refresh_token"\\s*:\\s*"([^"]+)"

# Only match JSON responses
content_type.pattern=(?i).*json.*|.*javascript.*|.*html.*

# Single capture group for the token value
groups.count=1

# Persist the refresh token across requests
group1.sticky=true

# Separate equivalency family for refresh tokens
# This prevents confusion with access tokens
equivalency.name.family=OAuth2-Refresh

# JSON unescaping for the token value
unescape.source=Only Javascript

# Enable this detector
detector=sread

# Platform detection metadata
platform=oauth2
detection.hint=JSON with "access_token", "refresh_token", "token_type", or "Bearer" authorization
