xqt commited on
Commit
f728e97
·
verified ·
1 Parent(s): 3eccb04

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +14 -8
main.py CHANGED
@@ -78,15 +78,14 @@ async def create_user(user: User):
78
  async def get_followers(channel_owner: str, limit: typing.Annotated[int, fastapi.Path(title = "The number of followers to retrieve")]):
79
  return {"channel_owner": channel_owner, "limit": limit}
80
 
81
- encryption_key = os.environ.get("ENCRYPTION_KEY")
82
- encryption_algorithm = os.environ.get("ENCRYPTION_ALGORITHM")
83
- if encryption_key is None:
84
- raise ValueError("No ENCRYPTION_KEY set for the application")
85
- if encryption_algorithm is None:
86
- raise ValueError("No ENCRYPTION_ALGORITHM set for the application")
87
-
88
-
89
  def encode_data(user: User):
 
 
 
 
 
 
 
90
  print(f"{encryption_key} and {encryption_algorithm}")
91
  print(jwt.get_algorithm_by_name(encryption_algorithm))
92
  payload = {
@@ -99,6 +98,13 @@ def encode_data(user: User):
99
  return payload
100
 
101
  def decode_data(token: str):
 
 
 
 
 
 
 
102
  try:
103
  payload = jwt.decode(token, encryption_key, algorithms = [encryption_algorithm])
104
  print(payload)
 
78
  async def get_followers(channel_owner: str, limit: typing.Annotated[int, fastapi.Path(title = "The number of followers to retrieve")]):
79
  return {"channel_owner": channel_owner, "limit": limit}
80
 
 
 
 
 
 
 
 
 
81
  def encode_data(user: User):
82
+ encryption_key = os.environ.get("ENCRYPTION_KEY")
83
+ encryption_algorithm = os.environ.get("ENCRYPTION_ALGORITHM")
84
+ if encryption_key is None:
85
+ raise ValueError("No ENCRYPTION_KEY set for the application")
86
+ if encryption_algorithm is None:
87
+ raise ValueError("No ENCRYPTION_ALGORITHM set for the application")
88
+
89
  print(f"{encryption_key} and {encryption_algorithm}")
90
  print(jwt.get_algorithm_by_name(encryption_algorithm))
91
  payload = {
 
98
  return payload
99
 
100
  def decode_data(token: str):
101
+ encryption_key = os.environ.get("ENCRYPTION_KEY")
102
+ encryption_algorithm = os.environ.get("ENCRYPTION_ALGORITHM")
103
+ if encryption_key is None:
104
+ raise ValueError("No ENCRYPTION_KEY set for the application")
105
+ if encryption_algorithm is None:
106
+ raise ValueError("No ENCRYPTION_ALGORITHM set for the application")
107
+
108
  try:
109
  payload = jwt.decode(token, encryption_key, algorithms = [encryption_algorithm])
110
  print(payload)