Skip to content

Commit 2a1777a

Browse files
committed
handle callback error
1 parent f5a8a0d commit 2a1777a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lexicons/com/atproto/sso/getCallback.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
"type": "query",
77
"parameters": {
88
"type": "params",
9-
"required": ["code", "state"],
9+
"required": ["state"],
1010
"properties": {
1111
"code": { "type": "string" },
12+
"error": { "type": "string" },
13+
"error_description": { "type": "string" },
1214
"state": { "type": "string" }
1315
}
1416
},

packages/pds/src/api/com/atproto/sso/getCallback.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ export default function (server: Server, ctx: AppContext) {
4343
)
4444
}
4545

46+
if (params.error) {
47+
const { error, error_description } = params;
48+
const description = error_description && ` (${error_description})`;
49+
50+
log.error(`Callback response returned error: ${error}${description}`);
51+
52+
throw new InvalidRequestError(`Callback response returned error: ${error}${description}`);
53+
}
54+
55+
if (!params.code) {
56+
log.error(params, "Missing code in callback response");
57+
58+
throw new InvalidRequestError(`Missing code in callback response`);
59+
}
60+
4661
const { code, state } = params;
4762

4863
if (!req.headers.cookie) {

0 commit comments

Comments
 (0)