question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

koa access_token missing from session

See original GitHub issue

I cloned the examples/koa-session-stores example, filled in my provider’s details and received the following error, despite the flow working successfully, indicating the the grant attribute was never added to the session:

Koa server listening on port 3000

  TypeError: Cannot read property 'response' of undefined
      at Object.<anonymous> (/private/var/tmp/grant/examples/koa-session-stores/koa-session.js:23:51)
      at Generator.next (<anonymous>)
      at Object.dispatch (/private/var/tmp/grant/examples/koa-session-stores/node_modules/koa-router/lib/router.js:317:7)
      at dispatch.next (<anonymous>)
      at Object.allowedMethods (/private/var/tmp/grant/examples/koa-session-stores/node_modules/koa-router/lib/router.js:356:5)
      at allowedMethods.next (<anonymous>)
      at onFulfilled (/private/var/tmp/grant/examples/koa-session-stores/node_modules/co/index.js:65:19)
      at /private/var/tmp/grant/examples/koa-session-stores/node_modules/co/index.js:54:5
      at new Promise (<anonymous>)
      at Object.co (/private/var/tmp/grant/examples/koa-session-stores/node_modules/co/index.js:50:10)

If I change the transport to querystring, the access_token is available in this.query. The exact same config.json works with the examples/session-transport example (which uses express) but I can’t seem to get the access_token to be properly stored in the session object with the koa-session example. It looks looks like the session object contains only the state, nonce, provider, and expiration. Very possible I’m misunderstanding the docs somewhere along the way.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
simovcommented, Jan 9, 2019

Thanks for the feedback, @drvan, this is really helpful! I’ll let you know when the next release is out with the new option to limit the response data in Grant. 👍

0reactions
simovcommented, Jan 11, 2019

Hi @drvan, I’ve published the response option.

Note that by default the response: 'tokens' will return all tokens as strings, including the id_token. That’s the smallest possible response.

In case you want to include the decoded id_token in the response data you have to use response: ['tokens', 'jwt'].

I’ve also pushed an example where I’m demonstrating how easy it is to decode the id_token yourself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can not get online access token · Issue #20 - GitHub
I have debugged through @shopify/koa-shopify-auth and Shopify returns online accessToken with associated_user and associated_user_scope but @ ...
Read more >
CustomSessionStorage using mysql, error missing access token
Solved: Hey, Currently trying to implement a custom session storage using MySQL. After I add the app it throws a missing access token...
Read more >
Koa ctx.session lost after redirect - Stack Overflow
Koa ctx.session lost after redirect · Navigate to localhost:8080 (Vue.js server) · Perform login by redirecting to Koa endpoint localhost:8081/api ...
Read more >
Authentication and authorization - Apollo GraphQL Docs
Control access to your GraphQL API · Authentication is determining whether a given user is logged in, and subsequently determining which user someone...
Read more >
Using the getSession function | SuperTokens Docs
On the other hand, getSession is a function which returns a session object on successful verification, and throws an exception which can be ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found