Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing clientContext in a Function locally #1

Closed
oliverjam opened this issue Aug 25, 2018 · 5 comments
Closed

Accessing clientContext in a Function locally #1

oliverjam opened this issue Aug 25, 2018 · 5 comments

Comments

@oliverjam
Copy link

oliverjam commented Aug 25, 2018

Hey Matt, thanks for the useful example. I was using your blog post to get started with authenticated Functions on Netlify, but I'm struggling to get it to work locally.

I'm sending the user jwt as a a bearer token in the authorization header and then accessing context.clientContext in the lamda. This works perfectly on my deployed site, but clientContext is always undefined locally even when I'm logged in.

Is this a limitation of the Identity and Functions integration or is there some configuration I need to do?

Edit: I've reproduced it at this URL https://friendly-jackson-0a3bb9.netlify.com. If you log in there and send a message you should see the response in dev tools come back with the claims in the body.

{
  "app_metadata": {
    "provider": "email"
  },
  "email": "[email protected]",
  "exp": 1535204013,
  "sub": "c3360574-b489-410d-9312-0bc8ea132d39",
  "user_metadata": {
    "full_name": "oli"
  }
}

If you clone the repo and run locally and do the same thing you get an empty object back.

@renschler
Copy link

I'm having the same issue @oliverjam @biilmann, also it's hard to test things in production bc we don't have access (afaik) to the lambda function logs, so running things locally would be awesome.

@oliverjam
Copy link
Author

FYI It looks like local lambdas don't support Identity for now: see this issue

@renschler you can access production lambda logs from your Netlify dashboard. Open up a site, go to the Functions page and then click a function to see the logs

screenshot 2018-11-29 at 10 59 52

screenshot 2018-11-29 at 11 00 00

@renschler
Copy link

Awesome thanks @oliverjam

@swyxio
Copy link

swyxio commented Jan 10, 2019

we support it now! netlify/netlify-lambda#57

@oliverjam
Copy link
Author

@sw-yx Yesss thank you! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants