Skip to main content
Authenticates using the device code flow. This method displays a link that the user must visit to authorize the application. If you’d like to handle the device code link yourself instead of it being printed to console, you can use the event_device_code_generated() event.

Class Signature

class DeviceCodeAuth(Auth):
    def __init__(self, open_link_in_browser: bool = True, **kwargs: Any) -> None

Parameters

Whether or not to automatically open the Epic Games login in the default browser.
ios_token
str
The main Fortnite token to use with authentication. You should generally not need to set this manually.
switch_token
str
The switch token to use with authentication. You should generally not need to set this manually.Default: OThmN2U0MmMyZTNhNGY4NmE3NGViNDNmYmI0MWVkMzk6MGEyNDQ5YTItMDAxYS00NTFlLWFmZWMtM2U4MTI5MDFjNGQ3

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 account ID.

Methods

eula_check_needed

def eula_check_needed() -> bool
Returns whether EULA check is needed. Returns: False (device code auth doesn’t require EULA check)

ios_authenticate

async def ios_authenticate(priority: int = 0) -> dict
Performs iOS authentication using device code flow.
priority
int
default:"0"
The request priority.
Returns: Authentication data dictionary Process:
  1. Obtains a switch token using client credentials
  2. Creates a device code
  3. Opens the verification URL in browser (if open_link_in_browser is True)
  4. Dispatches device_code_generated event or prints the URL
  5. Polls for user authorization
  6. Exchanges the device code for an access token
  7. Obtains an exchange code
  8. Exchanges the code for a session

authenticate

async def authenticate(priority: int = 0) -> None
Authenticates the client and sets up all required tokens.
priority
int
default:"0"
The request priority.
Side effects:
  • Updates iOS token data
  • Kills other sessions (if client.kill_other_sessions is True)
  • Obtains and updates chat, EAS, and EOS tokens
  • Sets up the client user

reauthenticate

async def reauthenticate(priority: int = 0) -> None
Used for reauthenticating if refreshing fails.
priority
int
default:"0"
The request priority.

Example Usage

import rebootpy

client = rebootpy.Client(
    auth=rebootpy.DeviceCodeAuth(
        open_link_in_browser=True
    )
)

# Handle the device code event if you want custom behavior
@client.event
async def event_device_code_generated(url):
    print(f'Please visit: {url}')
    # You could send this URL to a Discord channel, display in a UI, etc.

await client.start()

Error Handling

The device code flow handles several corrective actions automatically:
  • DATE_OF_BIRTH: If a date of birth is required, a random date is generated and submitted automatically
  • Authorization pending: The method polls every 10 seconds until authorization is complete
If an unsupported corrective action is required, an AuthException is raised.

Events

device_code_generated
event
Dispatched when the device code URL is generated.Parameters:
  • url (str): The verification URI to display to the user

Source

View source: rebootpy/auth.py:1186