- Let's switch to the Application details page of Logto Console. Add a Redirect URI{' '}
- {props.redirectUri} and click "Save changes".
-
+Let's switch to the Application details page of Logto Console. Add a Redirect URI {props.redirectUri} and click "Save changes".
diff --git a/docs/quick-starts/framework/vue/README.mdx b/docs/quick-starts/framework/vue/README.mdx
index c108c8a4517..f9d947db925 100644
--- a/docs/quick-starts/framework/vue/README.mdx
+++ b/docs/quick-starts/framework/vue/README.mdx
@@ -8,16 +8,12 @@ sidebar_custom_props:
import ApiResourcesDescription from '../../fragments/_api-resources-description.md';
import Checkpoint from '../../fragments/_checkpoint-test-your-application.md';
import FurtherReadings from '../../fragments/_further-readings.md';
-import GetUserInfoApis from '../../fragments/_get-user-info-apis.mdx';
-import ScopesAndClaims from '../../fragments/_scopes-and-claims.mdx';
+import GetUserInformation from './_get-user-information.mdx';
import GuideTip from './_guide-tip.mdx';
-import HandleAuthenticationStatus from './_handle-authentication-status.mdx';
-import ImplementSignIn from './_implement-sign-in.mdx';
-import ImplementSignOut from './_implement-sign-out.mdx';
+import ImplementSignInAndSignOut from './_implement-sign-in-and-sign-out.mdx';
import InitClient from './_init-client.mdx';
import Installation from './_installation.mdx';
-import ScopesAndClaimsCode from './_scopes-and-claims-code.mdx';
import ConfigApiResources from './api-resources/_config-api-resources.mdx';
import FetchAccessTokenForApiResources from './api-resources/_fetch-access-token-for-api-resources.mdx';
import FetchOrganizationTokenForUser from './api-resources/_fetch-organization-token-for-user.mdx';
@@ -44,25 +40,13 @@ This guide will show you how to integrate Logto into your Vue 3 application.
-### Implement sign-in
-
-
-
-### Implement sign-out
-
-
-
-### Handle authentication status
-
-
+
## Get user information
-
-
-} />
+
## API resources
@@ -80,6 +64,14 @@ This guide will show you how to integrate Logto into your Vue 3 application.
+### Attach access token to request headers
+
+Put the token in the `Authorization` field of HTTP headers with the Bearer format (`Bearer YOUR_TOKEN`), and you are good to go.
+
+:::note
+The Bearer Token's integration flow may vary based on the framework or requester you are using. Choose your own way to apply the request `Authorization` header.
+:::
+
## Further readings
diff --git a/docs/quick-starts/framework/vue/_get-user-information.mdx b/docs/quick-starts/framework/vue/_get-user-information.mdx
new file mode 100644
index 00000000000..aa0314ea7b7
--- /dev/null
+++ b/docs/quick-starts/framework/vue/_get-user-information.mdx
@@ -0,0 +1,97 @@
+import CodeBlock from '@theme/CodeBlock';
+
+import ClaimsNeedNetworkRequest from '../../fragments/_claims-need-network-request.mdx';
+import FindUserInfoMissing from '../../fragments/_find-user-info-missing.mdx';
+import ScopesAndClaims from '../../fragments/_scopes-and-claims.mdx';
+import ScopesAndClaimsIntroduction from '../../fragments/_scopes-claims-introduction.md';
+
+### Display user information
+
+To display the user's information, you can use the `getIdTokenClaims()` method. For example, in your Home page:
+
+```ts title="views/HomeView.vue"
+import { useLogto, type IdTokenClaims } from '@logto/vue';
+import { ref } from 'vue';
+
+const { isAuthenticated, getIdTokenClaims } = useLogto();
+const user = ref();
+
+if (isAuthenticated.value) {
+ (async () => {
+ const claims = await getIdTokenClaims();
+ user.value = claims;
+ })();
+}
+```
+
+```html
+
+
+
+
+
+
Name
+
Value
+
+
+
+
+
{{ key }}
+
{{ typeof value === "string" ? value : JSON.stringify(value) }}
+
+
+
+
+
+```
+
+### Request additional claims
+
+
+
+
+
+To request additional scopes, you can configure the Logto provider configs:
+
+```ts title="main.ts"
+import { createLogto, UserScope } from '@logto/vue';
+
+const app = createApp(App);
+
+app.use(createLogto, {
+ // ...other configs
+ // highlight-start
+ scopes: [
+ UserScope.Email,
+ UserScope.Phone,
+ UserScope.CustomData,
+ UserScope.Identities,
+ UserScope.Organizations,
+ ],
+ // highlight-end
+});
+app.use(router);
+```
+
+Then you can access the additional claims in the return value of `getIdTokenClaims()`:
+
+```ts
+const claims = await getIdTokenClaims();
+// Now you can access additional claims `claims.email`, `claims.phone`, etc.
+```
+
+{`const { fetchUserInfo } = useLogto();
+
+const userInfo = await fetchUserInfo();
+
+// Now you can access the claim \`userInfo.custom_data\``}
+}
+/>
+
+### Scopes and claims
+
+
diff --git a/docs/quick-starts/framework/vue/_handle-authentication-status.mdx b/docs/quick-starts/framework/vue/_handle-authentication-status.mdx
deleted file mode 100644
index 3246a7647f3..00000000000
--- a/docs/quick-starts/framework/vue/_handle-authentication-status.mdx
+++ /dev/null
@@ -1,29 +0,0 @@
-In Logto SDK, generally we can use `logtoClient.isAuthenticated` to check the authentication status, if the user is signed in, the value will be `true`, otherwise, the value will be `false`.
-
-In Logto Vue SDK, the `isAuthenticated` status can be checked by using the `useLogto` composable. In the example code below, we can use it to programmatically show and hide the sign-in and sign-out buttons. Also we'll use `getIdTokenClaims` to get the ID of the currently logged-in user.
-
-```tsx
-
-```
-
-```html
-
-
Logged in as {{ userId }}
-
-
-
-```
diff --git a/docs/quick-starts/framework/vue/_handle-redirect.mdx b/docs/quick-starts/framework/vue/_handle-redirect.mdx
index 45f4935b38d..14d750e17de 100644
--- a/docs/quick-starts/framework/vue/_handle-redirect.mdx
+++ b/docs/quick-starts/framework/vue/_handle-redirect.mdx
@@ -1,14 +1,13 @@
-### Handle redirect
+There are still things to do after the user is redirected back to your application from Logto. Let's handle it properly.
-We're almost there! In the last step, we use `http://localhost:3000/callback` as the Redirect URI, and now we need to handle it properly.
+First let's create a callback page:
-First let's create a callback component:
-
-```ts
-// CallbackView.vue
+```ts title="views/CallbackView.vue"
import { useHandleSignInCallback } from '@logto/vue';
+import router from '@/router';
+
const { isLoading } = useHandleSignInCallback(() => {
- // Navigate to root path when finished
+ // Do something when finished, e.g. redirect to home page
});
```
@@ -19,9 +18,9 @@ const { isLoading } = useHandleSignInCallback(() => {
```
-Finally insert the code below in your `/callback` route which does NOT require authentication:
+Insert the code below in your `/callback` route which does NOT require authentication:
-```ts
+```ts title="router/index.ts"
// Assuming vue-router
const router = createRouter({
routes: [
diff --git a/docs/quick-starts/framework/vue/_implement-sign-in-and-sign-out.mdx b/docs/quick-starts/framework/vue/_implement-sign-in-and-sign-out.mdx
new file mode 100644
index 00000000000..02ba072c895
--- /dev/null
+++ b/docs/quick-starts/framework/vue/_implement-sign-in-and-sign-out.mdx
@@ -0,0 +1,43 @@
+import SignInNote from '../../fragments/_sign-in-note.mdx';
+import AssumingUrl from '../../fragments/_web-assuming-url.md';
+import WebConfigureRedirectUris from '../../fragments/_web-configure-redirect-uris.mdx';
+import SignInFlowSummary from '../../fragments/_web-sign-in-flow-summary.mdx';
+import SignOutNote from '../../fragments/_web-sign-out-note.md';
+
+import HandleRedirect from './_handle-redirect.mdx';
+
+### Configure redirect URIs
+
+
+
+
+
+
+
+### Handle redirect
+
+
+
+### Implement sign-in and sign-out
+
+We provide two composables `useHandleSignInCallback()` and `useLogto()` which can help you easily manage the authentication flow.
+
+
+
+```tsx title="views/HomeView.vue"
+import { useLogto } from '@logto/vue';
+
+const { signIn, signOut, isAuthenticated } = useLogto();
+
+const onClickSignIn = () => signIn('http://localhost:3000/callback');
+const onClickSignOut = () => signOut('http://localhost:3000');
+```
+
+```html
+
+
+
+
+```
+
+
diff --git a/docs/quick-starts/framework/vue/_implement-sign-in.mdx b/docs/quick-starts/framework/vue/_implement-sign-in.mdx
deleted file mode 100644
index dfdb9080d13..00000000000
--- a/docs/quick-starts/framework/vue/_implement-sign-in.mdx
+++ /dev/null
@@ -1,35 +0,0 @@
-import redirectUriFigure from '../../assets/web-redirect-uri.png';
-import ConfigureRedirectUri from '../../fragments/_configure-redirect-uri.mdx';
-import SignInNote from '../../fragments/_sign-in-note.mdx';
-import SignInFlowSummary from '../../fragments/_web-sign-in-flow-summary.mdx';
-
-import HandleRedirect from './_handle-redirect.mdx';
-
-
-
-#### Configure sign-in redirect URI
-
-
-
-#### Implement a sign-in button
-
-We provide two composables `useHandleSignInCallback()` and `useLogto()` which can help you easily manage the authentication flow.
-
-
-
-Go back to your IDE/editor, use the following code to implement the sign-in button:
-
-```ts
-import { useLogto } from '@logto/vue';
-
-const { signIn } = useLogto();
-const onClickSignIn = () => signIn('http://localhost:3000/callback');
-```
-
-```html
-
-```
-
-#### Handle redirect
-
-
diff --git a/docs/quick-starts/framework/vue/_implement-sign-out.mdx b/docs/quick-starts/framework/vue/_implement-sign-out.mdx
deleted file mode 100644
index 484dd18aba7..00000000000
--- a/docs/quick-starts/framework/vue/_implement-sign-out.mdx
+++ /dev/null
@@ -1,16 +0,0 @@
-import SignOutNote from '../../fragments/_web-sign-out-note.md';
-
-
-
-#### Implement a sign-out button
-
-```ts
-import { useLogto } from '@logto/vue';
-
-const { signOut } = useLogto();
-const onClickSignOut = () => signOut('http://localhost:3000');
-```
-
-```html
-
-```
diff --git a/docs/quick-starts/framework/vue/_init-client.mdx b/docs/quick-starts/framework/vue/_init-client.mdx
index 8fae64eba1c..1363ff56578 100644
--- a/docs/quick-starts/framework/vue/_init-client.mdx
+++ b/docs/quick-starts/framework/vue/_init-client.mdx
@@ -1,17 +1,12 @@
-import AssumingUrl from '../../fragments/_web-assuming-url.md';
-
-
-
Import and use `createLogto` to install Logto plugin:
-```ts
-// main.ts
+```ts title="main.ts"
import { createLogto, LogtoConfig } from '@logto/vue';
import { createApp } from 'vue';
import App from './App.vue';
const config: LogtoConfig = {
- endpoint: '', // E.g. http://localhost:3001
+ endpoint: '',
appId: '',
};
diff --git a/docs/quick-starts/framework/vue/_installation.mdx b/docs/quick-starts/framework/vue/_installation.mdx
index f393812519e..0139dda0cd4 100644
--- a/docs/quick-starts/framework/vue/_installation.mdx
+++ b/docs/quick-starts/framework/vue/_installation.mdx
@@ -10,17 +10,17 @@ npm i @logto/vue
```
-
+
```bash
-yarn add @logto/vue
+pnpm add @logto/vue
```
-
+
```bash
-pnpm add @logto/vue
+yarn add @logto/vue
```
diff --git a/docs/quick-starts/framework/vue/_scopes-and-claims-code.mdx b/docs/quick-starts/framework/vue/_scopes-and-claims-code.mdx
deleted file mode 100644
index 2607c651d21..00000000000
--- a/docs/quick-starts/framework/vue/_scopes-and-claims-code.mdx
+++ /dev/null
@@ -1,19 +0,0 @@
-```tsx
-import { createLogto, UserScope } from "@logto/vue";
-
-...
-
-app.use(createLogto, {
- endpoint: '',
- appId: '',
- scopes: [
- UserScope.Email,
- UserScope.Phone,
- UserScope.CustomData,
- UserScope.Identities,
- UserScope.Organizations,
- ],
-});
-
-app.mount("#app");
-```
diff --git a/docs/quick-starts/framework/vue/api-resources/code/_config-organization-code.md b/docs/quick-starts/framework/vue/api-resources/code/_config-organization-code.md
index d2e25c84325..20cdcfe1c2a 100644
--- a/docs/quick-starts/framework/vue/api-resources/code/_config-organization-code.md
+++ b/docs/quick-starts/framework/vue/api-resources/code/_config-organization-code.md
@@ -1,8 +1,10 @@
-```ts
+```ts title="main.ts"
import { createLogto, UserScope } from '@logto/vue';
app.use(createLogto, {
// ...other configs
+ // highlight-start
scopes: [UserScope.Organizations],
+ // highlight-end
});
```
diff --git a/docs/quick-starts/framework/vue/api-resources/code/_config-resources-code.md b/docs/quick-starts/framework/vue/api-resources/code/_config-resources-code.md
index 310a6493659..0eba4403234 100644
--- a/docs/quick-starts/framework/vue/api-resources/code/_config-resources-code.md
+++ b/docs/quick-starts/framework/vue/api-resources/code/_config-resources-code.md
@@ -1,14 +1,9 @@
-```tsx
-import { createLogto } from "@logto/vue";
-
-...
+```ts title="main.ts"
+import { createLogto } from '@logto/vue';
app.use(createLogto, {
- endpoint: '',
- appId: '',
- // Add API resources
+ // ...other configs
+ // highlight-next-line
resources: ['https://shopping.your-app.com/api', 'https://store.your-app.com/api'],
});
-
-app.mount("#app");
```
diff --git a/docs/quick-starts/framework/vue/api-resources/code/_config-resources-with-scopes-code.md b/docs/quick-starts/framework/vue/api-resources/code/_config-resources-with-scopes-code.md
index 7ba84508f2b..33cd03ce3e5 100644
--- a/docs/quick-starts/framework/vue/api-resources/code/_config-resources-with-scopes-code.md
+++ b/docs/quick-starts/framework/vue/api-resources/code/_config-resources-with-scopes-code.md
@@ -1,10 +1,11 @@
-```tsx
+```ts title="main.ts"
import { createLogto } from '@logto/vue';
app.use(createLogto, {
- endpoint: '',
- appId: '',
+ // ...other configs
+ // highlight-start
scopes: ['shopping:read', 'shopping:write', 'store:read', 'store:write'],
resources: ['https://shopping.your-app.com/api', 'https://store.your-app.com/api'],
+ // highlight-end
});
```
diff --git a/docs/quick-starts/framework/vue/api-resources/code/_config-resources-with-shared-scopes-code.md b/docs/quick-starts/framework/vue/api-resources/code/_config-resources-with-shared-scopes-code.md
index 9a0e8330cae..eb7242653d6 100644
--- a/docs/quick-starts/framework/vue/api-resources/code/_config-resources-with-shared-scopes-code.md
+++ b/docs/quick-starts/framework/vue/api-resources/code/_config-resources-with-shared-scopes-code.md
@@ -1,10 +1,11 @@
-```tsx
+```ts title="main.ts"
import { createLogto } from '@logto/vue';
app.use(createLogto, {
- endpoint: '',
- appId: '',
+ // ...other configs
+ // highlight-start
scopes: ['read', 'write'],
resources: ['https://shopping.your-app.com/api', 'https://store.your-app.com/api'],
+ // highlight-end
});
```
diff --git a/docs/quick-starts/framework/vue/api-resources/code/_get-access-token-code.md b/docs/quick-starts/framework/vue/api-resources/code/_get-access-token-code.md
index c50ab87afa7..3c68e5ca511 100644
--- a/docs/quick-starts/framework/vue/api-resources/code/_get-access-token-code.md
+++ b/docs/quick-starts/framework/vue/api-resources/code/_get-access-token-code.md
@@ -1,4 +1,4 @@
-```tsx
+```ts title="views/HomeView.vue"
import { useLogto, type UserInfoResponse } from '@logto/vue';
const { isAuthenticated, getAccessToken } = useLogto();
diff --git a/docs/quick-starts/framework/vue/api-resources/code/_get-organization-access-token-code.md b/docs/quick-starts/framework/vue/api-resources/code/_get-organization-access-token-code.md
index 978e52d6b4f..cc5c53ef400 100644
--- a/docs/quick-starts/framework/vue/api-resources/code/_get-organization-access-token-code.md
+++ b/docs/quick-starts/framework/vue/api-resources/code/_get-organization-access-token-code.md
@@ -1,4 +1,4 @@
-```tsx
+```ts title="views/OrganizationsView.vue"
import { useLogto } from '@logto/vue';
import { onMounted, ref } from 'vue';
@@ -12,7 +12,7 @@ onMounted(async () => {
organizationIds.value = claims?.organizations;
});
-const onClickFetchOrgToken = async (organizationId: string) => {
+const onClickFetchOrganizationToken = async (organizationId: string) => {
console.log('raw token', await getOrganizationToken(organizationId));
console.log('claims', await getOrganizationTokenClaims(organizationId));
};
@@ -23,7 +23,7 @@ const onClickFetchOrgToken = async (organizationId: string) => {
{{ organizationId }}
-
diff --git a/tutorial/build-with-logto/_integrate-sdk-vue.mdx b/tutorial/build-with-logto/_integrate-sdk-vue.mdx
index 3ffbc4202d4..e0f6a6897d3 100644
--- a/tutorial/build-with-logto/_integrate-sdk-vue.mdx
+++ b/tutorial/build-with-logto/_integrate-sdk-vue.mdx
@@ -1,7 +1,5 @@
import GuideTip from '../../docs/quick-starts/framework/vue/_guide-tip.mdx';
-import HandleAuthenticationStatus from '../../docs/quick-starts/framework/vue/_handle-authentication-status.mdx';
-import ImplementSignIn from '../../docs/quick-starts/framework/vue/_implement-sign-in.mdx';
-import ImplementSignOut from '../../docs/quick-starts/framework/vue/_implement-sign-out.mdx';
+import ImplementSignInAndSignOut from '../../docs/quick-starts/framework/vue/_implement-sign-in-and-sign-out.mdx';
import InitClient from '../../docs/quick-starts/framework/vue/_init-client.mdx';
import Installation from '../../docs/quick-starts/framework/vue/_installation.mdx';
@@ -17,16 +15,8 @@ import TestYourIntegration from './fragments/_test-your-integration.mdx';
-### Implement sign-in
+### Implement sign-in and sign-out
-
-
-### Implement sign-out
-
-
-
-### Handle authentication status
-
-
+