+ Start a Discussion
binary_junkiebinary_junkie 

Chatter API - Org-wide auth tokens..?

Hello,

 

I'm trying to integrate a non-native app into chatter. I'd like to be able to make chatter updates for a user from a notification system.

 

Sample flow:

 

User updates task x, y, and z in App.

App server sends out notifications to various outlets (email, sms, chatter)

 

The problem I'm having:

I'm currently using the 'web server' flow. The original 'get token' call forces me to be logged in as a user. The token I'm given then pertains ONLY to that user (in this case, the admin). Ideally, I have a single token that I can use, then specify a username to impersonate. That doesn't appear to be the way OAuth2 works, though. That means I need a specific auth token for EVERY USER in the org to make this happen. What's the best way to accomplish this? I don't want every user to have to go to an 'activation' page where they so I can grab their token specifically. I need the admin to be able to do this.

 

Is there a way for an admin to export valid auth & refresh tokens for a group of users?

 

Cheers,

Matt

Best Answer chosen by Admin (Salesforce Developers) 
LoganLogan

You're right - posting on behalf of another user is not possible with the Chatter API.  I believe (have heard others do it but haven't done it myself) it is however with the SOAP api - you post as an administrator and manually set the parent id of the feed item to the desired user.

 

If you want to continue using the Chatter api a work around is to create a user in the org that is used specifically for notifications.  For example if your external app is called "Application A" then you give the user that name.  You login as that user and take only that user through the Oauth flow, saving its token.  Now when a real user comes to Application A and does something, it posts to Chatter.  The post could be to the real user's profile, or to Application A's profile.  If the latter, it gives the real users the option to receive (or not) updates by following Application A's user inside chatter.

All Answers

LoganLogan

You're right - posting on behalf of another user is not possible with the Chatter API.  I believe (have heard others do it but haven't done it myself) it is however with the SOAP api - you post as an administrator and manually set the parent id of the feed item to the desired user.

 

If you want to continue using the Chatter api a work around is to create a user in the org that is used specifically for notifications.  For example if your external app is called "Application A" then you give the user that name.  You login as that user and take only that user through the Oauth flow, saving its token.  Now when a real user comes to Application A and does something, it posts to Chatter.  The post could be to the real user's profile, or to Application A's profile.  If the latter, it gives the real users the option to receive (or not) updates by following Application A's user inside chatter.

This was selected as the best answer
binary_junkiebinary_junkie

Logan, thanks!

 

I hadn't even considered the possibility of doing it through the SOAP API! I'll post back with results after I've given it a shot.

 

Cheers!