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

How to get session information? #47

Open
alka7ex opened this issue Jan 28, 2024 · 5 comments
Open

How to get session information? #47

alka7ex opened this issue Jan 28, 2024 · 5 comments

Comments

@alka7ex
Copy link

alka7ex commented Jan 28, 2024

Hi guys.

I'm new here and just started using sveltekit with combination of clerk, amazing library it's make me easy to use clerk and it's almost done, however i got some challenges in my project.

sorry if the questions is a newbie questions
how i can access the session and claims information?, i have setup it in my clerk app, but i keep got nothing
image

i also get some issues where in my terminal i get error where the cookies is there but the token is not active

image

@danielgraziani91
Copy link

danielgraziani91 commented Apr 9, 2024

Hi! I had to add prop into the app.d.ts file.
image
To access everything right away just assign session to object.

@hbcondo
Copy link

hbcondo commented May 24, 2024

My session only returns an abbreviated user object as depicted below but the readme says it will get a Clerk user object which contains a lot more properties such as organizationMembers + permissions. Anyone know how to get all these clerk user property values?

  session: {
    userId: 'user_123',
    claims: {
      azp: 'http://localhost',
      exp: 1716510495,
      iat: 1716510435,
      iss: 'https://grown-pug.clerk.accounts.dev',
      nbf: 1716510425,
      sid: 'sess_123',
      sub: 'user_123'
    }
  }

@MariDjor
Copy link

MariDjor commented Jun 2, 2024

same here

@dizeeee
Copy link

dizeeee commented Jun 7, 2024

The readme is definitely not right from what I can tell. The server only validates the token, then includes the token info in locals. The backend doesn't seem to be creating a Clerk client, which seems like a requirement to get any user info.

@wobsoriano
Copy link

wobsoriano commented Jul 29, 2024

This PR in review but here's how to do it if it gets merged:

<script lang="ts">
	import { useClerkContext } from 'clerk-sveltekit/client'

        const { session } = useClerkContext()

	$: console.log($session)
</script>

in server you can access the auth object in locals via event.locals.auth

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

6 participants