Skip to content

Commit

Permalink
Finally some proper Oauth debugging!
Browse files Browse the repository at this point in the history
  • Loading branch information
spaceo committed Nov 18, 2024
1 parent 8d610f7 commit cd6d98f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
36 changes: 34 additions & 2 deletions app/auth/callback/unilogin/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,40 @@ export async function GET(request: NextRequest) {
const config = await getUniloginClientConfig()
const currentUrl = new URL(request.nextUrl.href)

// eslint-disable-next-line no-console
console.log("currentUrl URL: ", currentUrl)
// Debugging Oauth requests.
// TODO: Remove this later.
// const logRequest = (request: Request) => {
// // eslint-disable-next-line no-console
// console.log("Request URL: ", request.url.toString())
// // eslint-disable-next-line no-console
// console.log("Request Method: ", request.method)
// // eslint-disable-next-line no-console
// console.log("Request Body: ", request)
// // eslint-disable-next-line no-console
// console.log("-".repeat(100))
// }

// onfig[client.customFetch] = (...args) =>
// ky(args[0], {
// ...args[1],
// hooks: {
// beforeRequest: [
// request => {
// logRequest(request)
// },
// ],
// },
// })
config[client.customFetch] = async (url: string, options: RequestInit) => {
// eslint-disable-next-line no-console
console.log("Request URL: ", url.toString())
// eslint-disable-next-line no-console
console.log("Request Options: ", options)

const request = new Request(url, options)
return fetch(request)
}

// Fetch all user/token info.
try {
const tokenSetResponse = await client.authorizationCodeGrant(config, currentUrl, {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"framer-motion": "^11.11.10",
"graphql": "^16.9.0",
"iron-session": "^8.0.3",
"ky": "^1.7.2",
"lodash": "^4.17.21",
"lucide-react": "^0.446.0",
"next": "14.2.13",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7845,6 +7845,11 @@ keyv@^4.5.3:
dependencies:
json-buffer "3.0.1"

ky@^1.7.2:
version "1.7.2"
resolved "https://registry.yarnpkg.com/ky/-/ky-1.7.2.tgz#b97d9b997ba51ff1e152f0815d3d27b86513eb1c"
integrity sha512-OzIvbHKKDpi60TnF9t7UUVAF1B4mcqc02z5PIvrm08Wyb+yOcz63GRvEuVxNT18a9E1SrNouhB4W2NNLeD7Ykg==

language-subtag-registry@^0.3.20:
version "0.3.23"
resolved "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.23.tgz"
Expand Down

0 comments on commit cd6d98f

Please sign in to comment.