props.onNext(3)}
+>
+
+### Create LogtConfig
+
+
+
+{`// main.go
+func main() {
+ // ...
+
+ logtoConfig := &client.LogtoConfig{
+ Endpoint: "${props.endpoint}",
+ AppId: "${props.appId}",
+ AppSecret: "${props.appSecret}",
+ PersistAccessToken: true,
+ }
+
+ // ...
+}`}
+
+
+
+The `PersistAccessToken` config indicates whether the access token needs to be stored in the session.
+
+### Init LogtoClient for each user request
+
+```go
+// main.go
+func main() {
+ // ...
+
+ router.GET("/", func(ctx *gin.Context) {
+ // Init LogtoClient
+ session := sessions.Default(ctx)
+ logtoClient := client.NewLogtoClient(
+ logtoConfig,
+ &SessionStorage{session: session},
+ )
+
+ // Use Logto to control the content of the home page
+ authState := "You are not logged in to this website. :("
+
+ if logtoClient.IsAuthenticated() {
+ authState = "You are logged in to this website! :)"
+ }
+
+ homePage := `Hello Logto
` +
+ "" + authState + "
"
+
+ ctx.Data(http.StatusOK, "text/html; charset=utf-8", []byte(homePage))
+ })
+
+ // ...
+}
+```
+
+
+
+