Error: Unsuccessful response from data-sync: network [object Object]
Hello,
I face the following issue when I try to call an action from my data connector. I think I followed all the necessary steps to make it work.
I well start the demon based on the debug-server.ts file :
I well declare it in the manifest
I well defined the asynchronous actions
Here is the definition of the action :
Can someone help ?
Page 1 / 1
Hi Guillaume,
Sorry to hear you’re having trouble with the data connector. It seems like the request probably isn’t making it to your data connector. Could you share with me the code you’re using to send the data action from your editor extension?
Also, if you open the network tab of your browser developer tools and find the request going to /asynchronousAction it might have a more useful error message in the response. Would you mind sharing that as well?
Alex
Hi @ablackburn ,
Here is the code I use to call the data action :
I will have a look on the network tab to see if I see some hints about the issue
@ablackburn Here is the network tab result
Hi Guillaume,
From the second screenshot you sent it looks like your data connector is returning a 403 which indicates to me something is going on with the credential we’re trying to send on the network request to the data connector.
Have you uploaded your package to the developer dashboard and added a client id and secret for your OAuth provider?
Alex
@ablackburn I confirm you that I uploaded the package and added the client id and secret for the OAuth provider.
As you can see in my first screenshots, in the data connector, I only put a console.log() just to test if it works or not.
I don’t understand why I can’t see the log in the console
Hi Guillaume, I've been looking in further and I believe I misspoke. I don’t actually think we're making any request to your data connector.
Have you ever been sent through the flow which sends you to the OAuth provider, and asks for permission to let your Lucid extension access the data in that system?
The basic process we go through before the request gets to your data connector is:
Send a request from your extension to Lucid’s servers
Lucid’s servers look up the correct OAuth credential to go with that request
If the user hasn't yet authorized the extension, they should get redirected to the third party to authorize the extension.
Lucid's servers send the request to your data connector with the OAuth credential
If you're developing locally, we proxy this request through your browser using a websocket so we can hit your localhost address.
I believe we're getting stuck on step 2. I think we might have a bug in the flow that sends you to the OAuth provider when you're developing locally. I’m still looking into the details there.
In the meantime, my suggestion would be to upload and install your package in the Lucid Developer Dashboard, turn off local development in the Lucid editor where you're working with the extension. Then go through the flow which triggers the data action again. If things are working, it should send you to the OAuth provider at that point. If that works, you should be able to start developing locally again.
Hi @ablackburn
Thank you for your answer.
Indeed I never been sent through the flow which sends me to the OAuth provider and asks for permission. So you confirm that there is an issue on your side when developping locally ?
Also, I’m not sure to understand the step 2 : I configured an OAuth Provider and I’m able to log the result of this code in my extension :
But I don’t understand when I should be sent through the Oauth Provider flow for the extension permission since my data connector action only perform console.log() instruction
So you confirm that there is an issue on your side when developping locally ?
Yes, I can confirm this. I have replicated it and am working on a fix. I’ll keep you posted on my progress.
But I don’t understand when I should be sent through the Oauth Provider flow for the extension permission since my data connector action only perform console.log() instruction
This is supposed to happen automatically for you between the point where your extension calls `performDataAction`, and when we send the request to your data connector. Basically we take care of making sure the user has authorized your application and getting their authorization tokens stored off, and your data connector gets called once we've got the user's token ready to go. After the user has authorized the extension once, they don't need to go through the flow again since we’ve already got their token, so we just look it up and forward it to your data connector along with the request from your editor extension.
There is a workaround you can do by going through the authorization flow 1 time without running the extension locally. That should trigger the authorization flow and we will store your token off. After that, you should be able to develop locally again, because the bug appears to be happening specifically when we need to do that authorization step while doing local development.
Let me know if you have questions. I’ll follow back up with you when I've got a fix for the bug, but hopefully we can unblock you before then.
Alex
Hey Guillaume,
I looked in a bit further and uncovered a simpler workaround. If you have your extension call `editorClient.oauthXhr(...)` before you call `editorClient.performDataAction(...)` then the authorization flow will kick off correctly. Here’s an example:
Let me know if you're still stuck on anything, happy to help out more and/or jump on a call to get things unblocked! I’m working on fixes for the underlying bugs now.
Alex
@ablackburn I’m not sure to understand : you suggest to perform a server call before to trigger the data connector action ? What’s the point ?
As shared in previous a previous message, my data connector code only returns ‘{success: true} for the moment. I wanted to be sure that everything works.
And I can’t see your example with the lnk you provided :
Could you copy/paste a screenshot of an example code please ?
Hi Guillaume,
Appologies on the link, I didn't realize it would die when I updated the PR. Here's a permanent link to the code I wanted to share:
// Temporary workaround. You must call oauthXhr once before performDataAction will work const triggerOauth = await client.oauthXhr("lucid", { url: "https://api.lucid.co/folders/search", headers: { "Lucid-Api-Version": "1", "Content-Type": "application/json", }, data: "{}", method: "POST", }); const result = await client.performDataAction({ dataConnectorName: "data-connector-1", actionName: "Import", actionData: { message: "ImportFolders" }, asynchronous: true, });
The reason is due to a bug on our end that we're ironing out. Basically you must call `client.oauthXhr` once to trigger the authorization flow which fetches + stores the user’s OAuth token for use by the data connector.