Error with getCurrentMember() and createDraftPost() in Wix SDK using WixAppOauthStrategy: Failed to Fetch Current User

Question:
Why is the getCurrentMember() and createDraftPost() function in the Wix SDK with WixAppOauthStrategy returning an error, even though authentication is successfull with complete permissions?

Product:
Wix SDK, Wix API

What are you trying to achieve:
I’m trying to retrieve the current member’s information in Wix SDK using the getCurrentMember() function and use the current memberId to create a post using createDraftPost() function. Despite successfully authenticating using the Wix App OAuth strategy and other functions working correctly, this function consistently fails with a “FAILED_TO_FETCH_CURRENT_USER” error. My goal is to create draft posts based on the current member’s ID.

What have you already tried:
I have configured OAuth with proper app credentials and required permissions. Other functions like listMembers() work fine but not the getCurrentMember() and createDraftPost() .

Error: Failed to publish article to Wix: Error: {
"message": "UNAVAILABLE: Error fetching requester { siteMemberId: undefined }: UNKNOWN",
"details": {
"applicationError": {
 "description": "UNKNOWN",
"code": "FAILED_TO_FETCH_CURRENT_USER",
"data": {}
 }
}

Additional information:
Here’s a snippet of the code I’m using to authenticate and create a draft post:

const client = createClient({
    modules: { draftPosts, members },
    auth: WixAppOAuthStrategy({
        appId: WIX_APP_ID,
        appSecret: WIX_APP_SECRET,
        accessToken: ACCESS_TOKEN,
        refreshToken: REFRESH_TOKEN,
        instanceId: INSTANCE_ID
    }),
});
// const member = await client.members.getCurrentMember();
const response = await client.draftPosts.createDraftPost({
    memberId: MEMBER_ID,
    title: "Sample Title",
});

I’ve tried different approaches to get the current member’s ID, but the error persists. Any insights or solutions would be greatly appreciated.

The best place to report this is to the App Dev team: Wix Developers Login

1 Like

Got it! I just reported this issuè in the link you provided!

1 Like