Skip to main content
Authenticates using an Epic Games authorization code. This is one of the most straightforward authentication methods. You can get the code from this link by logging in and copying the code from the redirectUrl’s query parameters.

Getting an Authorization Code

  1. Visit the authorization URL
  2. Log in to your Epic Games account (or log out and log in to a different account)
  3. Copy the code parameter from the redirected URL
Authorization Code Example
An authorization code only works for a single login within a short timeframe (300 seconds). You need to get a new code for each login by refreshing the site.

Class Signature

class AuthorizationCodeAuth(ExchangeCodeAuth):
    def __init__(self, code: Union[str, Callable, Awaitable], **kwargs: Any) -> None

Parameters

code
Union[str, Callable, Awaitable]
required
The authorization code or a function/coroutine that when called returns the authorization code.This allows you to provide:
  • A string: "your-auth-code-here"
  • A function: lambda: get_code_from_somewhere()
  • An async function: async def get_code(): return await fetch_code()
device_id
str
A 32 char hex string representing your device.
ios_token
str
The main Fortnite token to use with authentication. You should generally not need to set this manually.

Properties

authorization
str
The Authorization header for use with Fortnite endpoints. Use this if you’re making HTTP requests that aren’t already implemented.
identifier
str
Returns the resolved authorization code.

Methods

ios_authenticate

async def ios_authenticate(priority: int = 0) -> dict
Performs iOS authentication using the authorization code.
priority
int
default:"0"
The request priority.
Returns: Authentication data dictionary Raises:
  • AuthException: If the authorization code is invalid or expired

Inherited Methods

Since AuthorizationCodeAuth extends ExchangeCodeAuth, it inherits the following methods:

authenticate

async def authenticate(priority: int = 0, **kwargs) -> None
Authenticates the client and sets up all required tokens.

resolve

async def resolve(code: Union[str, Callable, Awaitable]) -> str
Resolves a code from a string, callable, or awaitable.

Example Usage

With a static code

import rebootpy

client = rebootpy.Client(
    auth=rebootpy.AuthorizationCodeAuth(
        code='your-authorization-code-here'
    )
)

await client.start()

With a function

import rebootpy

def get_auth_code():
    # Read from a file, database, or prompt the user
    return input('Enter your authorization code: ')

client = rebootpy.Client(
    auth=rebootpy.AuthorizationCodeAuth(
        code=get_auth_code
    )
)

await client.start()

With an async function

import rebootpy
import aiofiles

async def get_auth_code():
    async with aiofiles.open('auth_code.txt', 'r') as f:
        return await f.read()

client = rebootpy.Client(
    auth=rebootpy.AuthorizationCodeAuth(
        code=get_auth_code
    )
)

await client.start()

Error Handling

If the authorization code is invalid or expired, an AuthException is raised with the message:
Invalid authorization code supplied
The underlying error will have the message code:
errors.com.epicgames.account.oauth.authorization_code_not_found

Comparison with ExchangeCodeAuth

AuthorizationCodeAuth is a specialized version of ExchangeCodeAuth that uses the authorization_code grant type instead of exchange_code. The main differences are:
  • AuthorizationCodeAuth: Uses codes from Epic’s authorization endpoint (easier to obtain)
  • ExchangeCodeAuth: Uses exchange codes from Epic’s exchange endpoint (more complex to obtain)
Both have the same 300-second expiration time and single-use limitation.

Source

View source: rebootpy/auth.py:586