Skip to content

Commit 298aa24

Browse files
committed
Fix indent in server.py
1 parent 06e9f2a commit 298aa24

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

00-Starter-Seed/server.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,24 @@ def get_token_auth_header():
4040
auth = request.headers.get("Authorization", None)
4141
if not auth:
4242
raise AuthError({"code": "authorization_header_missing",
43-
"description":
44-
"Authorization header is expected"}, 401)
43+
"description":
44+
"Authorization header is expected"}, 401)
4545

4646
parts = auth.split()
4747

4848
if parts[0].lower() != "bearer":
4949
raise AuthError({"code": "invalid_header",
50-
"description":
51-
"Authorization header must start with"
52-
"Bearer"}, 401)
50+
"description":
51+
"Authorization header must start with"
52+
" Bearer"}, 401)
5353
elif len(parts) == 1:
5454
raise AuthError({"code": "invalid_header",
55-
"description": "Token not found"}, 401)
55+
"description": "Token not found"}, 401)
5656
elif len(parts) > 2:
5757
raise AuthError({"code": "invalid_header",
58-
"description": "Authorization header must be"
59-
" Bearer token"}, 401)
58+
"description":
59+
"Authorization header must be"
60+
" Bearer token"}, 401)
6061

6162
token = parts[1]
6263
return token
@@ -88,12 +89,14 @@ def decorated(*args, **kwargs):
8889
unverified_header = jwt.get_unverified_header(token)
8990
except jwt.JWTError:
9091
raise AuthError({"code": "invalid_header",
91-
"description": "Invalid header. "
92-
"Use an RS256 signed JWT Access Token"}, 401)
92+
"description":
93+
"Invalid header. "
94+
"Use an RS256 signed JWT Access Token"}, 401)
9395
if unverified_header["alg"] == "HS256":
9496
raise AuthError({"code": "invalid_header",
95-
"description": "Invalid header. "
96-
"Use an RS256 signed JWT Access Token"}, 401)
97+
"description":
98+
"Invalid header. "
99+
"Use an RS256 signed JWT Access Token"}, 401)
97100
rsa_key = {}
98101
for key in jwks["keys"]:
99102
if key["kid"] == unverified_header["kid"]:
@@ -115,20 +118,22 @@ def decorated(*args, **kwargs):
115118
)
116119
except jwt.ExpiredSignatureError:
117120
raise AuthError({"code": "token_expired",
118-
"description": "token is expired"}, 401)
121+
"description": "token is expired"}, 401)
119122
except jwt.JWTClaimsError:
120123
raise AuthError({"code": "invalid_claims",
121-
"description": "incorrect claims,"
122-
" please check the audience and issuer"}, 401)
124+
"description":
125+
"incorrect claims,"
126+
" please check the audience and issuer"}, 401)
123127
except Exception:
124128
raise AuthError({"code": "invalid_header",
125-
"description": "Unable to parse authentication"
126-
" token."}, 400)
129+
"description":
130+
"Unable to parse authentication"
131+
" token."}, 400)
127132

128133
_app_ctx_stack.top.current_user = payload
129134
return f(*args, **kwargs)
130135
raise AuthError({"code": "invalid_header",
131-
"description": "Unable to find appropriate key"}, 400)
136+
"description": "Unable to find appropriate key"}, 400)
132137
return decorated
133138

134139

0 commit comments

Comments
 (0)