From midjourney-api-dev
Guides authentication setup with MidjourneyAuth — use when the user mentions 미드저니 로그인, 인증, 토큰, refresh token, MidjourneyAuth, .env token, cookie header, or Firebase auth
How this skill is triggered — by the user, by Claude, or both
Slash command
/midjourney-api-dev:midjourney-authThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Module: `midjourney_api.auth`
Module: midjourney_api.auth
MJ_REFRESH_TOKEN=your_firebase_refresh_token
The refresh token is a Firebase Auth token obtained via browser OAuth login.
from midjourney_api.auth import MidjourneyAuth
# Load from .env (default)
auth = MidjourneyAuth()
# Or provide directly
auth = MidjourneyAuth(refresh_token="AMf-vBw...")
# Custom .env path
auth = MidjourneyAuth(env_path="/path/to/.env")
MidjourneyAuth(
refresh_token: str | None = None, # explicit token (overrides .env)
env_path: str = ".env", # path to .env file
)
On init:
.env via python-dotenvMJ_REFRESH_TOKEN (unless explicit token provided)_do_refresh() to get an ID tokenauth.ensure_valid_token()
time.time() >= token_expiry - 60 (60-second buffer)id_token + refresh_token + expires_inPOST https://securetoken.googleapis.com/v1/token?key=<FIREBASE_API_KEY>
Content-Type: application/x-www-form-urlencoded
grant_type=refresh_token&refresh_token=<refresh_token>
Response:
{
"id_token": "eyJhbGci...",
"refresh_token": "AMf-vBw...",
"expires_in": "3600"
}
id_tokenmidjourney_id field → used as user_id for all API callscookie_str = auth.cookie_header()
# → "__Host-Midjourney.AuthUserTokenV3_i=<id_token>; __Host-Midjourney.AuthUserTokenV3_r=<refresh_token>"
All API requests require this cookie header.
| Property | Type | Description |
|---|---|---|
auth.user_id | str | Midjourney user ID (from JWT). Raises AuthenticationError if not authenticated |
auth.id_token | str | Current ID token (auto-refreshes if expired) |
auth = MidjourneyAuth()
auth.login() # Opens Chromium browser for Google OAuth
https://www.midjourney.com/__Host-Midjourney.AuthUserTokenV3_r.env as MJ_REFRESH_TOKEN=...Requires: playwright install chromium (playwright is a core dependency)
MidjourneyClient manages auth internally:
# Auth is automatic — just set MJ_REFRESH_TOKEN in .env
with MidjourneyClient() as client:
job = client.imagine("hello world")
# Or login via client
client = MidjourneyClient()
client.login() # opens browser
from midjourney_api.auth import MidjourneyAuth
from midjourney_api.api import MidjourneyAPI
auth = MidjourneyAuth()
api = MidjourneyAPI(auth)
# auth.ensure_valid_token() is called automatically by api._request()
| Exception | When |
|---|---|
AuthenticationError("Not authenticated...") | user_id accessed before login/refresh |
AuthenticationError("No refresh token...") | ensure_valid_token() with no token |
AuthenticationError("Token refresh failed...") | Firebase API returns HTTP error |
AuthenticationError("midjourney_id not found...") | JWT missing midjourney_id field |
Creates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.
npx claudepluginhub juyeongyi/jylee_claude_marketplace --plugin midjourney-api-dev