With the go-sdk, is there a way to use my user's t...
# ory-network
r
With the go-sdk, is there a way to use my user's token to get the session info server side? I'm currently stuck on:
Copy code
client.V0alpha2Api.ToSession(o.ctx, ...)
1
I think there's a not in my brain, so it turns out, this would work:
Copy code
req, err := http.NewRequestWithContext(o.ctx, http.MethodGet, fmt.Sprintf("%s/sessions/whoami"), nil)
	if err != nil {
		return nil, err
	}

	req.Header.Set("Authorization", fmt.Sprintf("bearer %s", token))
	res, err := <http://http.DefaultClient.Do|http.DefaultClient.Do>(req)
	if err != nil {
		return nil, err
	}
But is there a way to use the sdk?
m
Should be FrontendApi instead of V0alpha2Api (see SDK v1 guide) but yea, something like
.toSession({ cookie: req.header("cookie") })
or are you not using cookie?
r
yeah, not using cookie
but I am also a bit stuck
My service is behind oathkeeper, and oathkeeper decodes the cookie/token and gives me
X-Username: foo
. I forgot about this part before I went down the rabbithole. And now I am actually trying to look up the user based on username.
I probably have to use the admin api
m
Ah you look up the user in Ory Identities? Did you see this? https://ory-community.slack.com/archives/C02MR4DEEGH/p1676560474760299
I am not sure if username is possible, but email an option?
r
I really need username
new sdk is nice 👍
I like the readability
now just wondering where to find an endpoint that lets me maybe iterate over identities
c
APIClient.IdentityApi.ListIdentities
🙂
r
thx
yeah