Skip to content

Commit

Permalink
Release v1.2
Browse files Browse the repository at this point in the history
Release v1.2
  • Loading branch information
Nazar1ky authored Aug 17, 2024
2 parents 841030c + 8ef61dd commit 9554a3c
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 77 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1 align="center">Epic Games Friends Remover</h1>
<p align="center">
<a href="https://www.python.org/downloads/release/python-380/" align="center">
<img alt="Python" src="https://img.shields.io/badge/python-3.8 | 3.9 | 3.10 | 3.11 | 3.12-blue">
<img alt="Python" src="https://img.shields.io/badge/python-3.12-blue">
</a>
<a href="https://github.com/Nazar1ky/epic-games-store-remove-all-friends/issues" align="center">
<img alt="GitHub Issues" src="https://img.shields.io/github/issues/Nazar1ky/epic-games-store-remove-all-friends">
Expand All @@ -14,7 +14,8 @@
</a>
</p>

<img src="https://github.com/Nazar1ky/epic-games-store-remove-all-friends/blob/main/pic.png" />
## Preview:
<img src="pic.png" />

## Description
This script remove all your friends in 5 seconds for Epic Games Store. Open Source, you can download code and edit it. if you Windows user you can download latest exe from [releases](https://github.com/Nazar1ky/epic-games-store-remove-all-friends/releases) or [Github Actions](https://github.com/Nazar1ky/epic-games-store-remove-all-friends/actions).
Expand Down
179 changes: 104 additions & 75 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,91 +2,115 @@

import requests
from rich.console import Console
from rich.prompt import Confirm

TIMEOUT_IN_SECONDS = 10

class DeleteFriends:
# CLIENT_ID:SECRET
CLIENT = b"98f7e42c2e3a4f86a74eb43fbb41ed39:0a2449a2-001a-451e-afec-3e812901c4d7"


class FriendsRemover:
def __init__(self) -> None:
# https://github.com/MixV2/EpicResearch/blob/master/docs/auth/auth_clients.md
self.client = base64.b64encode(
b"98f7e42c2e3a4f86a74eb43fbb41ed39:0a2449a2-001a-451e-afec-3e812901c4d7",
CLIENT,
).decode(
"utf-8",
)

self.console = Console()
self.session = requests.Session()

self.session.headers.update = {
"Content-Type": "application/x-www-form-urlencoded",
}

self.account_id = None
self.bearer = None

def run(self) -> None:
console = Console()
console.clear()

console.print("[yellow bold]Epic Games Store Friends Remover")

token = self.create_token()
self.auth_link, self.device_code = self.device_code(token)
token = self.token()["access_token"]

def run(self) -> bool:
self.console.clear()
self.console.print("[yellow bold]Epic Games Store Friends Remover")
device_code = self.device_code(token)

self.console.input(
f"[green bold]Verify login [/green bold][yellow](click enter to continue)[/yellow][green bold]:[/green bold] [red]{self.auth_link}",
console.input(
f"[bold][green]Login (press enter to continue):[/green] [red]{device_code["verification_uri_complete"]}",
)
data = self.device_code_verify(self.device_code)

if not data["success"]:
self.console.print(f"[red][bold][ERROR][/bold] {data['error_message']}")
return False
try:
data = self.device_code_verify(device_code["device_code"])
except requests.HTTPError:
console.print("[red]User not logged in!")
return

self.data = data
self.account_id = data["account_id"]
self.bearer = data["access_token"]

self.console.print(f"[green]Successfully logged in [bold]{self.data['display_name']}")
console.print(f"[bold][green]Successfully logged in [blue]{data['displayName']}")

self.console.print("[green]Removing Friends...")
friends = self._get_friends()

friends_count = self.get_friend_count()
self.delete_friends()
friends_count = len(friends["friends"])

self.console.print(
f"[green bold]Removed {friends_count} friends![/green bold] [yellow]You can kill all sessions to reset token.",
confirm = Confirm.ask(
f"[bold][yellow]You have [blue]{friends_count} [yellow]friends! "
"You sure you want to remove all friends?",
)

self.console.input()
if not confirm:
return

return None
self._remove_friends()

# Reference: https://github.com/MixV2/EpicResearch/blob/master/docs/auth/grant_types/client_credentials.md
def create_token(self) -> str:
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": f"basic {self.client}",
}
body = {
"grant_type": "client_credentials",
}
self._kill_session()

console.print(
f"[bold][green]Removed {friends_count} friends!\n[yellow]Session has been killed",
)

console.input()

def token(self) -> dict:
"""https://github.com/MixV2/EpicResearch/blob/master/docs/auth/grant_types/client_credentials.md"""
headers = {"Authorization": f"basic {self.client}"}

data = requests.post(
body = {"grant_type": "client_credentials"}

response = self.session.post(
"https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token",
headers=headers,
data=body,
timeout=TIMEOUT_IN_SECONDS,
).json()
)

return data["access_token"]
response.raise_for_status()

# Reference: https://github.com/LeleDerGrasshalmi/FortniteEndpointsDocumentation/blob/main/EpicGames/AccountService/Authentication/DeviceCode/Create.md
def device_code(self, token) -> tuple:
return response.json()

def device_code(self, token: str) -> dict:
"""https://github.com/LeleDerGrasshalmi/FortniteEndpointsDocumentation/blob/main/EpicGames/AccountService/Authentication/DeviceCode/Create.md"""
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": f"bearer {token}",
}

data = requests.post(
"https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/deviceAuthorization",
response = self.session.post(
"https://account-public-service-prod.ol.epicgames.com/account/api/oauth/deviceAuthorization",
headers=headers,
timeout=TIMEOUT_IN_SECONDS,
).json()
)

return data["verification_uri_complete"], data["device_code"]
response.raise_for_status()

return response.json()

# Reference: https://github.com/MixV2/EpicResearch/blob/master/docs/auth/grant_types/device_code.md
def device_code_verify(self, device_code) -> dict:
"""https://github.com/MixV2/EpicResearch/blob/master/docs/auth/grant_types/device_code.md"""
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": f"basic {self.client}",
}

Expand All @@ -95,55 +119,60 @@ def device_code_verify(self, device_code) -> dict:
"device_code": device_code,
}

data = requests.post(
response = self.session.post(
"https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token",
headers=headers,
data=body,
timeout=TIMEOUT_IN_SECONDS,
).json()

if "errorCode" in data:
return {
"success": False,
"error_code": data["errorCode"],
"error_message": data["errorMessage"],
}

return {
"success": True,
"display_name": data["displayName"],
"account_id": data["account_id"],
"access_token": data["access_token"],
}
)

response.raise_for_status()

# Reference: https://github.com/LeleDerGrasshalmi/FortniteEndpointsDocumentation/blob/main/EpicGames/FriendsService/Friends/FriendsList.md
def get_friend_count(self) -> int:
return response.json()

def _get_friends(self) -> dict:
"""https://github.com/LeleDerGrasshalmi/FortniteEndpointsDocumentation/blob/main/EpicGames/FriendsService/Friends/FriendsList.md"""
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": f"bearer {self.data['access_token']}",
"Authorization": f"bearer {self.bearer}",
}

data = requests.get(
f"https://friends-public-service-prod.ol.epicgames.com/friends/api/v1/{self.data['account_id']}/summary",
response = self.session.get(
f"https://friends-public-service-prod.ol.epicgames.com/friends/api/v1/{self.account_id}/summary",
headers=headers,
timeout=TIMEOUT_IN_SECONDS,
).json()
)

response.raise_for_status()

return len(data["friends"])
return response.json()

# Reference: https://github.com/LeleDerGrasshalmi/FortniteEndpointsDocumentation/blob/main/EpicGames/FriendsService/Friends/Clear.md
def delete_friends(self) -> None:
def _remove_friends(self) -> None:
"""https://github.com/LeleDerGrasshalmi/FortniteEndpointsDocumentation/blob/main/EpicGames/FriendsService/Friends/Clear.md"""
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": f"bearer {self.data['access_token']}",
"Authorization": f"bearer {self.bearer}",
}

self.session.delete(
f"https://friends-public-service-prod.ol.epicgames.com/friends/api/v1/{self.account_id}/friends",
headers=headers,
timeout=TIMEOUT_IN_SECONDS,
)

def _kill_session(self) -> None:
"""https://github.com/LeleDerGrasshalmi/FortniteEndpointsDocumentation/blob/main/EpicGames/FriendsService/Friends/Clear.md"""
headers = {
"Authorization": f"bearer {self.bearer}",
}

requests.delete(
f"https://friends-public-service-prod.ol.epicgames.com/friends/api/v1/{self.data["account_id"]}/friends",
self.session.delete(
f"https://account-public-service-prod.ol.epicgames.com/account/api/oauth/sessions/kill/{self.bearer}",
headers=headers,
timeout=TIMEOUT_IN_SECONDS,
)

def main() -> None:
friends_remover = FriendsRemover()
friends_remover.run()

if __name__ == "__main__":
app = DeleteFriends().run()
main()
Binary file modified pic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9554a3c

Please sign in to comment.