Developer Questions

Ask a Question
Back to All

Possible to authorize in React Native using xumm universal SDK?

Here's the setup I'm currently trying:

// from expo-auth-session
const [request, response, promptAsync] = useAuthRequest(
    {
      clientId: process.env.EXPO_PUBLIC_XUMM_API_KEY,
      redirectUri: 'origami://',
    },
    {
      authorizationEndpoint: 'https://oauth2.xumm.app/auth',
    },
  );

This works! It opens up the xumm app and allows me to fulfill the signing request. The response then returns an authorization_code, code, and state. I think this is the point where I'm going wrong...

I re-initialize the xumm SDK, i.e.

XummSdk = new Xumm(authorization_code);
const pong = await XummSdk.ping();
console.log({ pong }); // pong is undefined :(

Unfortunately, it doesn't seem to be authenticated, so I expect there's some extra magic that needs to happen to properly initialize Xumm. I have console warnings telling me that properties are missing (i.e. payload), and various environment properties are undefined as well, implying to me that it's not authenticated.

What am I missing? Thanks!