Skip to main content
ArcBlock Community

oauth session refresh issue

voidmanevoid
Support
did-spacesimpact-highqualifiedresolvedrewardedsdk

it looks like oauth is working now for connecting a did space!

i have to refresh after i connect to spaces for the first time. is it possible after the user connects to spaces to refresh the session context?

here is the applicable code:

import { createAuthServiceSessionContext } from '@arcblock/did-connect/lib/Session'; import { useContext } from 'react';

const { SessionProvider, SessionContext, SessionConsumer, withSession } = createAuthServiceSessionContext();

function useSessionContext() { const info = useContext(SessionContext); return info as any; }

export { SessionProvider, SessionContext, SessionConsumer, useSessionContext, withSession };

const { session } = useSessionContext();

useEffect(() => { console.log(logged in, session); }, [session]);

this session useEffect gets called when they login but not after they connect their did space.

7 replies

wangshijun20 months ago

Great suggestions, we will publish an improved version of @arcblock/did-connect this week, please stay tuned.

By the way, you can wrap code in your post in an code block for better readability, 😄

You can trigger that by using "/" command, or using the editor toolbar.

Screenshot 2025-01-06 at 07.23.57.png

voidmanevoid20 months ago

sounds great! can't wait.

thanks!

JianChao20 months ago

z1e4XATJSo1Y1jom17Uhj1SpKZ4LFmYSaHY

This feature is now supported, subscribe to DID Space events. Currently, all OAuth accounts will trigger this event when DID Space is successfully presented. Please update versions of @arcblock/ux and @arcblock/did-connect to 2.11.19 and above. For code examples, please refer to(subscribe EVENTS.DID_SPACE_CONNECTED event):  Subscribe to DID Connect Events

voidmanevoid20 months ago

thank you! i'll update and try it out. can't wait!

voidmanevoid20 months ago

once i updated those two packages, i received these errors:

javascriptCopy

(2025-01-08 14:48:32): ✘ [ERROR] No matching export in "node_modules/@arcblock/did-connect/lib/constant.js" for import "AUTH_SERVICE_PREFIX"
(2025-01-08 14:48:32):
(2025-01-08 14:48:32):     node_modules/@blocklet/ui-react/lib/ComponentInstaller/use-component-installed.js:1:9:
(2025-01-08 14:48:32):       1 │ import { AUTH_SERVICE_PREFIX } from '@arcblock/did-connect/lib/cons...
(2025-01-08 14:48:32):         ╵          ~~~~~~~~~~~~~~~~~~~
(2025-01-08 14:48:32):
(2025-01-08 14:48:32): ✘ [ERROR] No matching export in "node_modules/@arcblock/ux/lib/Util/constant.js" for import "WELLKNOWN_SERVICE_PATH_PREFIX"
(2025-01-08 14:48:32):
(2025-01-08 14:48:32):     node_modules/@blocklet/ui-react/lib/BlockletStudio/index.js:2:9:
(2025-01-08 14:48:32):       2 │ import { WELLKNOWN_SERVICE_PATH_PREFIX } from "@arcblock/ux/lib/Uti...
(2025-01-08 14:48:32):         ╵          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(2025-01-08 14:48:32):
(2025-01-08 14:48:32): ✘ [ERROR] No matching export in "node_modules/@arcblock/ux/lib/Util/constant.js" for import "AUTH_SERVICE_PREFIX"
(2025-01-08 14:48:32):
(2025-01-08 14:48:32):     node_modules/@blocklet/ui-react/lib/UserCenter/libs/utils.js:3:9:
(2025-01-08 14:48:32):       3 │ import { AUTH_SERVICE_PREFIX } from "@arcblock/ux/lib/Util/constant";
(2025-01-08 14:48:32):         ╵          ~~~~~~~~~~~~~~~~~~~
(2025-01-08 14:48:32):
(2025-01-08 14:48:32): ✘ [ERROR] No matching export in "node_modules/@arcblock/ux/lib/Util/constant.js" for import "WELLKNOWN_SERVICE_PATH_PREFIX"
(2025-01-08 14:48:32):
(2025-01-08 14:48:32):     node_modules/@blocklet/ui-react/lib/ComponentManager/components/publish-component.js:5:9:
(2025-01-08 14:48:32):       5 │ import { WELLKNOWN_SERVICE_PATH_PREFIX } from "@arcblock/ux/lib/Uti...
(2025-01-08 14:48:32):         ╵          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(2025-01-08 14:48:32):
(2025-01-08 14:48:32): ✘ [ERROR] No matching export in "node_modules/@arcblock/ux/lib/Util/constant.js" for import "WELLKNOWN_SERVICE_PATH_PREFIX"
(2025-01-08 14:48:32):
(2025-01-08 14:48:32):     node_modules/@blocklet/ui-react/lib/ComponentManager/components/add-component.js:5:9:
(2025-01-08 14:48:32):       5 │ import { WELLKNOWN_SERVICE_PATH_PREFIX } from "@arcblock/ux/lib/Uti...
(2025-01-08 14:48:32):         ╵          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(2025-01-08 14:48:32):
wangshijun20 months ago

Hi, please upgrade following packages to latest to resolve this issue:

  • @arcblock/ux
  • @arcblock/did-connect
  • @blocklet/ui-react
voidmanevoid20 months ago

thank you!

everything works as expected now!!

i login using my gmail, then connect did spaces using gmail for the first time, then our blocklet can write to the users did space.

Reply