Send HTTP200 when oauth2 is successful

This commit is contained in:
Ali Parlakci
2021-03-27 23:17:37 +03:00
parent 265505efc7
commit 2e879949f5

View File

@@ -62,6 +62,7 @@ class OAuth2Authenticator:
self.send_message(client) self.send_message(client)
raise RedditAuthenticationError(f'Error in OAuth2: {params["error"]}') raise RedditAuthenticationError(f'Error in OAuth2: {params["error"]}')
self.send_message(client, "<script>alert('You can go back to terminal window now.')</script>")
refresh_token = reddit.auth.authorize(params["code"]) refresh_token = reddit.auth.authorize(params["code"])
return refresh_token return refresh_token
@@ -80,8 +81,8 @@ class OAuth2Authenticator:
return client return client
@staticmethod @staticmethod
def send_message(client: socket.socket): def send_message(client: socket.socket, message: str):
client.send('HTTP/1.1 200 OK'.encode('utf-8')) client.send(f'HTTP/1.1 200 OK\r\n\r\n{message}'.encode('utf-8'))
client.close() client.close()