- Notifications
You must be signed in to change notification settings - Fork 407
/
Copy pathget-session.go
33 lines (26 loc) · 675 Bytes
/
get-session.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package session
import (
"context"
"github.com/ory/client-go"
)
typeoryMiddlewarestruct {
ory*ory.APIClient
}
funcinit() {
cfg:=client.NewConfiguration()
cfg.Servers= client.ServerConfigurations{
{URL: fmt.Sprintf("https://%s.projects.oryapis.com", os.Getenv("ORY_PROJECT_SLUG"))},
}
ory=client.NewAPIClient(cfg)
}
funcGetSession(ctx context.Context, sessionIdstring, expandOptions []string) (session*client.Session, errerror) {
// highlight-start
session, _, err=ory.IdentityApi.GetSession(ContextWithToken(ctx), sessionId).
Expand(expandOptions).
Execute()
// highlight-end
iferr!=nil {
returnnil, err
}
returnsession, err
}