question

Kamron Clark avatar image
Kamron Clark asked Phong Vu commented

Post to team as a different user

When I use the team messaging create post endpoint, it posts a message with my extension as the author. Is it possible to make the author of the post a different extension user, one made specifically for using the API? The documentation doesn't seem to show a parameter for specifying author of the post. If it is always the "logged in" user, is there a way to change that user? I'm using JWT authorization flow and Node.js client libraries.

Here is my current code:

async function create_post() {
    try {
        var resp = await platform.post('/restapi/v1.0/glip/chats/chatid/posts', {
            text: 'Testing...'
        });
        var jsonObj = await resp.json();
        console.log("Post Created");
        console.log(jsonObj);
    } catch(e) {
        console.log(e.message);
    }
}
rest api
1 |3000

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

1 Answer

Phong Vu avatar image
Phong Vu answered Phong Vu commented

Unfortunately, this is not allowed. The server automatically identifies the user using the access token and post messages for that user. So if you need to post on behalf of another user, you need to have the access token of that user.

2 comments
1 |3000

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

Kamron Clark avatar image Kamron Clark commented ·

I figured it was such. Is there a way to obtain the access token of another user and use it to post, or is it something that can't be changed when it comes to a production app?

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ Kamron Clark commented ·

There are 2 options.

1. Implement your app with 3-legged authentication and after the user logs in, keep the refresh token and use it to get new access token. You have to maintain the refresh token to make sure it will not expire.

2. Ask user to provide their JWT token and use that to exchange for the access token every time you need.

2 Likes 2 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys