MCPcopy
hub / github.com/Skyvern-AI/skyvern / _create_local_access_token

Function _create_local_access_token

skyvern/cli/mcp.py:31–47  ·  view source on GitHub ↗
(subject: str, expires_delta: timedelta)

Source from the content-addressed store, hash-verified

29
30
31def _create_local_access_token(subject: str, expires_delta: timedelta) -> str:
32 from skyvern.config import settings # noqa: PLC0415
33
34 if settings.SIGNATURE_ALGORITHM != "HS256":
35 raise RuntimeError("Local quickstart token bootstrap only supports HS256 SIGNATURE_ALGORITHM")
36
37 expire = datetime.utcnow() + expires_delta
38 header = {"alg": "HS256", "typ": "JWT"}
39 payload = {"exp": int(expire.timestamp()), "sub": str(subject)}
40 signing_input = ".".join(
41 [
42 _base64url_encode(json.dumps(header, separators=(",", ":")).encode("utf-8")),
43 _base64url_encode(json.dumps(payload, separators=(",", ":")).encode("utf-8")),
44 ]
45 )
46 signature = hmac.new(settings.SECRET_KEY.encode("utf-8"), signing_input.encode("ascii"), hashlib.sha256).digest()
47 return f"{signing_input}.{_base64url_encode(signature)}"
48
49
50async def get_or_create_local_organization(database: Any | None = None) -> Organization:

Calls 4

_base64url_encodeFunction · 0.85
joinMethod · 0.80
encodeMethod · 0.80
dumpsMethod · 0.80

Tested by

no test coverage detected