Get Session Status
Poll the status of a JIT authentication session. Use this to know when the user has completed OAuth authorization.
Request
curl https://api.mcprank.com/v1/identity/sessions/sess_abc123 \
-H "X-API-Key: sk_mcp_rank_..."
Path Parameters
The session ID returned from Create Auth Session
Response
Session status: pending, complete, or error
Error message if status is error
Status Values
| Status | Meaning |
|---|
pending | User hasn’t completed auth yet - keep polling |
complete | Auth successful - tokens stored, ready to make requests |
error | Auth failed - check error field for details |
Example Responses
Pending:
Complete:
Error:
{
"status": "error",
"error": "User denied access"
}
Polling Example
import asyncio
async def wait_for_auth(client, session_id, timeout=300):
"""Poll until auth completes or times out."""
elapsed = 0
while elapsed < timeout:
status = await client.check_session_status(session_id)
if status["status"] == "complete":
return True
elif status["status"] == "error":
raise Exception(f"Auth failed: {status.get('error')}")
await asyncio.sleep(1)
elapsed += 1
raise Exception("Auth timed out")
Notes
- Poll every 1-2 seconds
- Sessions expire after 5 minutes
- Once
complete, you should call initialize() to refresh the client’s MIT
- The session ID is single-use - don’t poll after receiving
complete or error