question

shaun-mclean6109 avatar image
shaun-mclean6109 asked ·

How can I specify a user as host for a meeting when authenticated with the admin account in an API

I have an App in production with permission Meetings and can successfully create a Meeting with the API for the admin account. I want to be able via my script to authenticate on the admin account and then pass through the details for a user in the account so the meeting is created with the user as host. I tried using the number I see for each user in the Admin Portal url but that is not working.

How do I get a valid host id for each user and pass it via the API Create Meeting?

apimeetingshost
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered ·

Can you try to read the user's extension id then create a meeting with that extension id

https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/[extensionId]/meeting
5 comments Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

So do I have to make a different App for every user? That seems odd. When I authenticate to the App it is with the admin credentials - when attempting to create a meeting for another user if I set host id to what I believe is the correct internal extension id I get a "errorCode":"MET-106"

"message":"Cannot create meeting. Reason : [Provider internal error]" error and if I set both extension id and host id with the internal user id I get "errorCode":"CMN-101"

"message":"Parameter [extensionId] value is invalid"

Perhaps I'm using the incorrect extension Id but how do I get extension IDs for users unless my App has the ReadAccounts permission? Do I need to create a whole other App with ReadAccounts, get it approved to Production just so I can get the correct IDs. Perhaps I'm missing the obvious here but I'm having trouble finding much documentation on this. Appreciate your help on this @Phong Vu

0 Likes 0 · ·

I tested myself and it works well. I just modified my answer to show better the [accountId], which you don't need to specify but can use the tilde ~.

I have working code in Node JS. Let me know if you want the code. It is simple though.

0 Likes 0 · ·

Unfortunately I can't even get this to work in the API Reference interface that RC offers at https://developers.ringcentral.com/api-reference/Meeting-Management/createMeeting
Not sure what's wrong but I've submitted a ticket and hope it gets resolved

0 Likes 0 · ·
Show more comments
Show more comments
Phong Vu avatar image
Phong Vu answered ·

@Joseph Kaylen

Here is the code in Node JS. remember that it works on production. You can try on sandbox if your sandbox has been enabled Meeting feature

const RingCentral = require('@ringcentral/sdk').SDK

RINGCENTRAL_CLIENTID = "your-app-client-id"
RINGCENTRAL_CLIENTSECRET = "your-app-client-secret"
RINGCENTRAL_SERVER = 'https://platform.ringcentral.com'

RINGCENTRAL_USERNAME = 'main-company-number'
RINGCENTRAL_PASSWORD = '101-password'
RINGCENTRAL_EXTENSION = '101'

const rcsdk = new RingCentral({
  server: RINGCENTRAL_SERVER,
  clientId: RINGCENTRAL_CLIENTID,
  clientSecret: RINGCENTRAL_CLIENTSECRET
})

var platform = rcsdk.platform();

platform.login({
        username: RINGCENTRAL_USERNAME,
        extension: RINGCENTRAL_EXTENSION,
        password: RINGCENTRAL_PASSWORD
      })

platform.on(platform.events.loginSuccess, () => {
  read_user_extension_id()
})

async function read_user_extension_id(){
    console.log("read_user_extension_id")
    try{
      var resp = await platform.get('/restapi/v1.0/account/~/extension')
      var jsonObj = await resp.json()
      for (var record of jsonObj.records){
        if (record.extensionNumber == 102){ // e.g. 101 creates a meeting for 102
            console.log(record)
            create_meeting(record.id)
        }
      }
    }catch(e){
      console.log(e.message)
    }
}

async function create_meeting(id){
    console.log("Schedule a meeting for: " + id)
    var endpoint == `/restapi/v1.0/account/~/extension/${id}/meeting`
  try{
    var resp = await platform.post(endpoint, {
              topic: 'Test Meeting',
              meetingType: 'Instant',
              allowJoinBeforeHost: false,
              startHostVideo: true,
              startParticipantsVideo: false
        })
    var jsonObj = await resp.json()
    console.log( 'Start Your Meeting: ' + jsonObj.links.startUri )
    console.log( 'Meeting id: ' + jsonObj.id )
  }catch(e){
    console.log(e.message)
  }
}
Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Joseph Kaylen avatar image
Joseph Kaylen answered ·

Thank you very much Phong!

I didn't realize record.ID (as used in the meeting endpoint), did not equal Extension Number. Wow! That would've taken forever for me to determine.

Does your 101 account have permissions do create meetings on behalf of all users? Or does each user have to go into settings and add your 101 account to 'Schedule Meetings for Me'?


I am referencing this article: https://medium.com/ringcentral-developers/programmatically-manage-others-meetings-a96cd8a9653f (about halfway down).

Sorry for all the questions, but my sandbox account does not yet have [Meetings] enabled. I sent an email earlier today with my paid account information, so hopefully it gets turned on soon.

I would almost prefer each user has to modify their Schedule Meetings for Me settings, rather then using the Super Admin account.

2 comments Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

I did not test on sandbox yet but I can try it later. I've tested to login with a standard user and schedule a meeting for another standard user (e.g. ext. 103 schedules for ext. 102 and it also works).

I am going to chat with the author of the article and will ask him to retest his code and edit the article accordingly.

For your sandbox, what is your sandbox main company number or account id?


Hold on. It seems working only for Instant meeting. I just tested with meetingType = "Scheduled" and it failed. Let me investigate a bit more then give you an update.

1 Like 1 · ·
Joseph Kaylen avatar image Joseph Kaylen Phong Vu ♦♦ ·

Thank you for the follow-up! Account information is below. I am building the middleware so that the Learning Management System our company sells can automatically create RingCentral meetings for Instructors when they host a Training Event. We have integrations with WebEx, GoTo Meeting, and others, but not yet RingCentral.

Production Main Account (Cornerstone Ondemand): +19493934961
Production My Extension: 580098
My Sandbox Account: 14244335649

0 Likes 0 · ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.