Skip to main content

I am currently building a Web-App with monetization. That beeing said to keep it simple i want to only use the Web SDK and do not want to use Rest API. Nevertheless i am associating the access_granted of the App with the Miro user_id. So in order to see wether a user has linked his user_id with a license key of mine i would need to request the user_id in the Web SDK. Is this somehow possible? I stumbled accross some old community posts, that do not seem to be relevant anymore as some functions got deprecated with the new Web SDK.

 

I am looking forward to your suggestions as i would really like to avoid needing to make use of the Rest API in this case.

Thank you very much!!

Hey @Maximilian Steverding,

First, it’s great to hear you’re working on an app that incorporates monetization! 

As for your question regarding getting the user ID for a user’s session when using our Web SDK, we’re working on adding more details around this in our documentation and guides—you’ve raised a great point.

In order to do this, I might recommend following the same workflow that @Vedran mentions in his blog post here: 
Building and Monetizing Miro Apps

Under the section titled “Use the authentication feature included with the Miro Web SDK”, you can follow his suggestion to leverage the board.getIdToken() function that will expose the Miro user ID.

I hope this helps, and thanks a lot for raising this!

Best,
Will


Good Morning @Will Bishop ,

thank you for your reply! Luckily I already managed to get the user_id through the Web SDK with the function Miro.board.getUserInfo(), which returns the user_id. Through the Miro.board.getOnlineUsers() I than compare the user_id of the user with all active users to also get the associated username for the user_id. That is sufficient for me as I already implemented a stripe workflow and user verification etc. 

The great thing with user_ids is that for “login” the user into the service one can hijack the Miro login and simply associate the user_id with a license key to grant access to the server without the need for a special login within the app. 

 

For reference here is the workflow of first catching the users id and than getting their username (verify() is the function that handles the login process which I have not copied here):

 

async function identify(){

await miro.board.getUserInfo()

.then(res => getUserName(res.id))

.then(test => verify(test));

}

 

async function getUserName(user_id){

const onlineUsers = await miro.board.getOnlineUsers();

 

onlineUsers.forEach(element => {

if(element.id == user_id){

username = element.name;

userid = element.id;

}

});

return;

}


That’s great to hear, Maximilian!

Thanks a lot for sharing your workflow as well 😊


Reply