-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented login directly via Plex webhook
- Loading branch information
1 parent
8e7a201
commit 45b4559
Showing
15 changed files
with
417 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import requests | ||
|
||
|
||
class PlexAuth: | ||
def __init__(self, client_id): | ||
self.client_id = client_id | ||
self.base_url = 'https://plex.tv/api/v2' | ||
self.headers = { | ||
'X-Plex-Product': 'SuggestArr', | ||
'X-Plex-Client-Identifier': self.client_id, | ||
"Accept": 'application/json' | ||
} | ||
|
||
def get_authentication_pin(self): | ||
"""Genera un nuovo pin di autenticazione.""" | ||
response = requests.post(f"{self.base_url}/pins?strong=true", headers=self.headers) | ||
data = response.json() | ||
auth_url = f"https://app.plex.tv/auth#?clientID={self.client_id}&code={data['code']}" | ||
return data['id'], auth_url | ||
|
||
def check_authentication(self, pin_id): | ||
"""Verifica se l'utente ha completato l'autenticazione.""" | ||
response = requests.get(f"{self.base_url}/pins/{pin_id}", headers=self.headers) | ||
data = response.json() | ||
if 'authToken' in data: | ||
print(data) | ||
return data['authToken'] | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.