You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For advanced use cases, you may need direct access to the user's identity. You can use `getIdentityOnce` to retrieve the identity if the user is currently authenticated.
110
+
111
+
:::caution
112
+
113
+
Use this function **imperatively only**. Do **not** persist the identity in global state or store it for reuse. This function is intended for short-lived, one-time operations only.
114
+
115
+
:::
116
+
117
+
```ts
118
+
import { getIdentityOnce } from"@junobuild/core";
119
+
120
+
// Returns null if the user is not authenticated
121
+
const identity =awaitgetIdentityOnce();
122
+
123
+
if (identity!==null) {
124
+
// Use the identity to perform calls on the Internet Computer
125
+
}
126
+
```
127
+
128
+
Typical use case for this function is to enable developers to implement custom features for the Internet Computer:
129
+
130
+
- Passing the identity to temporarily create an actor or agent to call a canister
131
+
- Signing a message or making a one-time authenticated call
0 commit comments