Domanda

My solution may not be technically possible. Yet I would like your viewpoint We have to create a workflow/plugin MS-CRM 2013 which will publish events from CRM to a particular facebook page.

  1. A separate application is not possible.
  2. The problem is, to publish I need Page Access Token.
  3. To get Page Access Token I need User Access Token.
  4. To get User Access Token I need to follow the redirect_uri path where I will get the code in URL string but MS-CRM 2013 as you might be aware does not allow "code" as url string, it will refuse to redirect itself to my callback page, that is my problem.

I am open to suggestions I have used Facebook SDK and simple webrequest.this gives me the App Access Token

dynamic result = obj.Get("oauth/access_token", new
                {
                    client_id = this.fbAppID,
                    client_secret = this.fbAppSecret,
                    grant_type = "client_credentials",
                    scope = "publish_actions,manage_pages,create_event,read_stream,publish_stream,email,read_friendlists,read_insights,read_requests,manage_friendlists,user_about_me,user_activities,user_birthday,user_groups,friends_groups"
                });

Now How do I get the user access token from inside MS-CRM 2013 online. If somebody has done it please do let me know, if you need more clarification I will be happy to provide more code etc.

È stato utile?

Soluzione

You need to separate your logic:

  1. Create an HTML/JavaScript WebResource combo that allows a user to link their CRM SystemUser record to Facebook. Build code similar to that below - it'll need additional supporting code to check if the user is already connected to Facebook, etc.

FB.login(function (response) { if (response.authResponse) { // user sucessfully logged in var accessToken = response.authResponse.accessToken; //TODO: Add logic to save accessToken to CRM SystemUser record. } }, { scope: 'email,publish_stream,email,rsvp_event,read_stream,user_likes,user_birthday' });

  1. In your plugin retrieve the FB Access Token, saved in step 1, from the CRM SystemUser record, and use that to instantiate your Facebook connection object:

var obj = new FacebookClient(accessToken);

This is a bunch of work to do to get the access token. And none of the guides are going to clearly explain mixing pure HTML/JS for token retrieval but making the calls from C#, since this is a fairly unusual requirement.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top