Having trouble using monday.setToken within the Apps SDK

Hi all

I am starting to use the SDK to develop apps with dashboard features. I am just building some proof of concept simple apps at the moment, to test API queries.

I am able to upload an app as a dashboard feature, query data using the sdk and render it, which is great. I am taking advantage of seamless auth provided by the monday.api() method.

I now would like to start developing more efficiently, so i am trying to pass a token with the queries, so that i can debug in my local environment (rather than having to build and upload every time). I have tried using monday.setToken(‘api_token_provided_in_the_admin_section_of_monday.com’)

and i have also tried passing the same within the options parameter of the monday.api method.

when running locally, the api returns the error saying i am not authenticated (as if i had passed an incorrect token or no token at all).

I triple checked the token i am passing. I am using the same in a raw query using Postman and that returns the data i expect.

Help would be most appreciated, let me know if you need more information on the issue.

Thanks!

Hey @jaacquees.
Can you share further details and some pieces of code?

hey @jaacquees – you also mentioned you want to develop your client-side apps more efficiently. I would recommend using ngrok for local development, because it streamlines the workflow. That way you don’t have to rely on a build-upload process each time, but can still use seamless authentication and see your results in monday.com.

Essentially, you run ngrok http [port] and the tool will generate a URL that you can put in the “view setup” testing section of your app feature.

You can install it globally or run it from inside our starter code (it’s bundled as a dev dependency).

Check out our quickstart video (around 2:40) to see it in action: https://monday.com/developers/apps/quickstart-view

Many thanks Dipro. I managed to create the tunnel and hook up the embedded app to my debugger (using webstorm right now). Breakpoints work, which is great.

Thanks again!

thanks Rob. I’ll just go with dipro’s suggestion for now, but i am interested in resolving the issue about setToken:

async getAllBoardNames():Promise<MondayItem>{
var result = await this.monday.api(
query{ boards{ id name } },{token:this.tkn}
);

  return result.data.boards as Board[];

}

it doesn’t work and result is just {errors:[“Not Authenticated”]}

Hey, I am facing the same problem.
I used my api key in https://monday.com/developers/v2/try-it-yourself and it’s working great.
But plugging it into my ngrok development and viewing it live in widget setup preview and using
monday.setToken(apikey)
or
monday.api(query/mutation, {token: apikey})…
Neither work and I get the message: error: Not Authenticated

Leaving out the token info doesn’t work either, but am I misunderstanding the documentation when it says “If not set, will use the credentials of the current user (client only)”. Should it work anyway?