Skip to content

Instantly share code, notes, and snippets.

@fl0wo
Last active December 12, 2022 20:51
Show Gist options
  • Select an option

  • Save fl0wo/d615b7f151f4f7308e2f11c4004c5c9e to your computer and use it in GitHub Desktop.

Select an option

Save fl0wo/d615b7f151f4f7308e2f11c4004c5c9e to your computer and use it in GitHub Desktop.
Integration of token.ts
export const handler: any = async (event:any) => {
try {
const code = event.queryStringParameters!.code;
const jwtKey = await getParameterValue(
wrapCodeWithPrefix(code)
);
const expiresIn = whenJwtExpiresLocal(jwtKey);
if (Number.isInteger(expiresIn)) {
const removed = await removeParameterValue(
wrapCodeWithPrefix(code)
);
}
return {
statusCode: 200,
body: JSON.stringify({
success: true,
data: {
access_token:jwtKey,
id_token:jwtKey,
expires_in: expiresIn
},
}),
headers: {
"Access-Control-Allow-Headers": "*",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "*",
},
};
} catch (e) {
console.error(e);
return {
statusCode: 500,
body: JSON.stringify(e, null, 2),
headers: {
"Access-Control-Allow-Headers": "*",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "*",
},
};
}
};
@fl0wo
Copy link
Copy Markdown
Author

fl0wo commented Dec 12, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment