Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/airweave/core/source_connection_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,8 @@ async def _create_with_oauth_token(
"refresh_token": obj_in.authentication.refresh_token,
"token_type": "Bearer",
}
if obj_in.authentication.expires_at:
oauth_creds["expires_at"] = obj_in.authentication.expires_at.isoformat()
if obj_in.authentication.expires_in:
oauth_creds["expires_in"] = obj_in.authentication.expires_in

# Validate config
validated_config = await self._validate_config_fields(
Expand Down
10 changes: 6 additions & 4 deletions backend/airweave/schemas/source_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ class OAuthTokenAuthentication(BaseModel):

access_token: str = Field(..., description="OAuth access token")
refresh_token: Optional[str] = Field(None, description="OAuth refresh token")
expires_at: Optional[datetime] = Field(None, description="Token expiry time")
expires_in: Optional[int] = Field(
None, description="Token expiry time in seconds (standard OAuth2 format)"
)

@model_validator(mode="after")
def validate_token(self):
"""Validate token is not expired."""
if self.expires_at and self.expires_at < datetime.utcnow():
raise ValueError("Token has already expired")
"""Validate expires_in is positive if provided."""
if self.expires_in is not None and self.expires_in <= 0:
raise ValueError("expires_in must be positive")
return self


Expand Down
11 changes: 5 additions & 6 deletions fern/definition/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4575,18 +4575,17 @@
"title": "Refresh Token",
"description": "OAuth refresh token"
},
"expires_at": {
"expires_in": {
"anyOf": [
{
"type": "string",
"format": "date-time"
"type": "integer"
},
{
"type": "null"
}
],
"title": "Expires At",
"description": "Token expiry time"
"title": "Expires In",
"description": "Token expiry time in seconds (standard OAuth2 format)"
}
},
"type": "object",
Expand Down Expand Up @@ -8381,4 +8380,4 @@
"optional": true
}
]
}
}
Loading