Skip to content

Commit c97ae34

Browse files
committed
feat: return platform and cat_id in token exchange response
1 parent fdc8d5d commit c97ae34

10 files changed

Lines changed: 20 additions & 1034 deletions

grpc_services/v3/exchange_oauth2_code.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ def ExchangeOAuth2CodeAndStore(self, request, context):
9999
token_id=token.token_id,
100100
server_ephemeral_public_keys=server_public_keys,
101101
key_id=kid_index,
102+
platform=adapter["name"],
103+
cat_id=adapter["cat_id"],
102104
)
103105

104106
except NotImplementedError as exc:

grpc_services/v3/exchange_pnba_code.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ def ExchangePNBACodeAndStore(self, request, context):
9191
return response(
9292
success=True,
9393
two_step_verification_enabled=True,
94+
platform=adapter["name"],
95+
cat_id=adapter["cat_id"],
9496
message="two-steps verification is enabled and a password is required",
9597
)
9698

@@ -120,6 +122,8 @@ def ExchangePNBACodeAndStore(self, request, context):
120122
token_id=token.token_id,
121123
server_ephemeral_public_keys=server_public_keys,
122124
key_id=kid_index,
125+
platform=adapter["name"],
126+
cat_id=adapter["cat_id"],
123127
)
124128

125129
except NotImplementedError as exc:

platforms/adapter_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ def get_adapter_path(cls, name: str, protocol: str) -> Optional[dict]:
252252
"path": manifest.get("path"),
253253
"venv_path": manifest.get("venv_path"),
254254
"assets_path": manifest.get("assets_path"),
255+
"cat_id": int(manifest.get("cat_id")),
256+
"name": manifest.get("name"),
255257
}
256258

257259
logger.warning(

protos/v3/publisher.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ message ExchangeOAuth2CodeAndStoreResponse {
9090
repeated PublicKey server_ephemeral_public_keys = 6;
9191
// Key ID used for encrypting the token ciphertext
9292
uint32 key_id = 7;
93+
// The platform name
94+
string platform = 8;
95+
// Category identifier
96+
uint32 cat_id = 9;
9397
}
9498

9599
// Request message for revoking an OAuth2 token
@@ -181,6 +185,10 @@ message ExchangePNBACodeAndStoreResponse {
181185
repeated PublicKey server_ephemeral_public_keys = 7;
182186
// Key ID used for encrypting the token ciphertext
183187
uint32 key_id = 8;
188+
// The platform name
189+
string platform = 9;
190+
// Category identifier
191+
uint32 cat_id = 10;
184192
}
185193

186194
// Request message for revoking and deleting a PNBA token

tests/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ def cmd_exchange_oauth2_code(args: argparse.Namespace) -> bool:
159159

160160
tokens = db_get("tokens") or {}
161161
tokens[response.account_identifier] = {
162-
"platform": args.platform,
162+
"platform": response.platform,
163+
"cat_id": response.cat_id,
163164
"account_identifier": response.account_identifier,
164165
"token": b64(raw_token),
165166
"token_id": b64(response.token_id),
@@ -402,7 +403,8 @@ def cmd_exchange_pnba_code(args: argparse.Namespace) -> bool:
402403

403404
tokens = db_get("tokens") or {}
404405
tokens[response.account_identifier] = {
405-
"platform": args.platform,
406+
"platform": response.platform,
407+
"cat_id": response.cat_id,
406408
"account_identifier": response.account_identifier,
407409
"token": b64(raw_token),
408410
"token_id": b64(response.token_id),

tests/conftest.py

Lines changed: 0 additions & 133 deletions
This file was deleted.

0 commit comments

Comments
 (0)