# Authorizing SocialMediaData through JLink or custom Front End

**URL:** <https://community.wolfram.com/t/authorizing-socialmediadata-through-jlink-or-custom-front-end/591>\
**Category:** Questions\
**Tags:** software-development, mathematica, external-interfaces\
**Created:** [September 22, 2013, 1:26am UTC](https://community.wolfram.com/t/authorizing-socialmediadata-through-jlink-or-custom-front-end/591 "2013-09-22T01:26:36Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![borlaj2](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@borlaj2](https://community.wolfram.com/u/borlaj2)\
**Post date:** [September 22, 2013, 1:26am UTC](https://community.wolfram.com/t/authorizing-socialmediadata-through-jlink-or-custom-front-end/591/1 "2013-09-22T01:26:36Z")

</div>

I am trying to use SocialMediaData through JLink. Functions that don’t require authorization such as SocialMediaData[“Facebook”,“Properties”] work fine, but when I try to do something like SocialMediaData[“Facebook”, “Friends”] I get a packet back saying “A front end is not available; certain operations require a front end.” Presumably, the front end is required to ask the user for the facebook access key. Is there a way to give the kernel the access key programmatically through JLink, or alternatively, to write my own front end that could imitate Mathematica’s front end for the purpose of returning the access key to the kernel?

---

<div class="post-metadata">

**Author:** ![seanc](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/seanc/32/34005_2.png) [@seanc](https://community.wolfram.com/u/seanc)\
**Post date:** [September 23, 2013, 2:07pm UTC](https://community.wolfram.com/t/authorizing-socialmediadata-through-jlink-or-custom-front-end/591/2 "2013-09-23T14:07:05Z")

</div>

Try using Developer`UseFrontEnd. Is there something about your machine which is preventing you from using the front end? or where you looking to script this?

```auto
Developer`UseFrontEnd[SocialMediaData["Facebook","Friends"]]

```

---

<div class="post-metadata">

**Author:** ![borlaj2](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@borlaj2](https://community.wolfram.com/u/borlaj2)\
**Post date:** [September 23, 2013, 3:20pm UTC](https://community.wolfram.com/t/authorizing-socialmediadata-through-jlink-or-custom-front-end/591/3 "2013-09-23T15:20:53Z")

</div>

I’m accessing JLink from within a web server, so it can’t open a front end that the client can see. P.S. the original post says “updating name” but it was me. Not sure why except maybe I posted too soon after creating the account.

---

<div class="post-metadata">

**Author:** ![borlaj2](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@borlaj2](https://community.wolfram.com/u/borlaj2)\
**Post date:** [September 23, 2013, 10:17pm UTC](https://community.wolfram.com/t/authorizing-socialmediadata-through-jlink-or-custom-front-end/591/4 "2013-09-23T22:17:06Z")

</div>

It appears that I can invoke “MathLink`SetFrontEnd[$ParentLink]” through a MathLink connection and then it thinks I’m the front end. At this point a lot of reverse engineering would probably have to happen to actually imitate a front end. We will see how far I get.

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/szhorvat/32/3531_2.png) [@szhorvat](https://community.wolfram.com/u/szhorvat)\
**Post date:** [September 24, 2013, 1:20am UTC](https://community.wolfram.com/t/authorizing-socialmediadata-through-jlink-or-custom-front-end/591/5 "2013-09-24T01:20:23Z")

</div>

If there’s no supported way to do this (as it seems), reverse engineering it is going to be rather difficult because all the relevant symbols are Locked.

I think that if you want to provide a service like this, you will need to create your own Facebook application that will help with exporting the data (and you’ll need to take responsibility for it as a Facebook app developer). It’ll need to be authorized in a similar way to how SocialMediaData is. Before this function was available, I used [NameGen](http://mysocnet.oii.ox.ac.uk/fb/namegen4preview.php), which may be helpful for you to study how this works.

The documented version of Developer`UseFrontEnd is UsingFrontEnd.

---

<div class="post-metadata">

**Author:** ![brucem](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/brucem/32/26319_2.png) [@brucem](https://community.wolfram.com/u/brucem)\
**Post date:** [September 24, 2013, 5:42pm UTC](https://community.wolfram.com/t/authorizing-socialmediadata-through-jlink-or-custom-front-end/591/6 "2013-09-24T17:42:24Z")

</div>

Sorry about the “Updating Name”.  
We are aware of the issue and are working on it.

Your name will be fixed - no need to repost this or change how you create posts. .

---

<div class="post-metadata">

**Author:** ![borlaj2](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@borlaj2](https://community.wolfram.com/u/borlaj2)\
**Post date:** [October 21, 2013, 5:11pm UTC](https://community.wolfram.com/t/authorizing-socialmediadata-through-jlink-or-custom-front-end/591/7 "2013-10-21T17:11:01Z")

</div>

Indeed, I came to a dead end as far as imitating the front end. I got farther than I thought I would, though. I like that MathLink is transparent enough to at least give a glimpse of what is going on.

Another approach I thought to try was to override a function within Mathematica. For example, I tried this, using an access token than I had retrieved with my own code:

```auto
HTTPClient`OAuthAuthentication[consumerKey_,consumerSecret_,
    authorizeEndpoint_,accessEndpoint_,redirectURI_,
    oauthVersion_,accessTokenExtractor_]=
  HTTPClient`OAuthToken[HTTPClient`OAuth`Private`OAuth20Parameters["graph.facebook.com",
      None,Automatic,"verifier",Automatic,Automatic,"(my consumer key here)",
      "(my consumer secret here)","https://www.facebook.com/dialog/oauth","RemoveWhitespace",
      "https://graph.facebook.com/oauth/access_token","GET",
      "https://www.facebook.com/connect/login_success.html","Text/2.0","None"],
      HTTPClient`OAuth`Private`Token20["(my valid access token here)"]]

```

But then when I try this:

```auto
token = HTTPClient`OAuthAuthentication[
"ConsumerKey" -> "(my consumer key)",
"ConsumerSecret" -> "(my consumer secret)",
"AuthorizeEndpoint" -> "https://www.facebook.com/dialog/oauth",
"AccessEndpoint" -> "https://graph.facebook.com/oauth/access_token",
"RedirectURI" -> "https://www.facebook.com/connect/login_success.html",
"OAuthVersion" -> "2.0",
"AccessTokenExtractor" -> "Text/2.0"]

```

The regular oauth dialog pops up, as if the function had not been overridden. Have I done this incorrectly? Or is this function somehow locked? I tried using “unprotect” but that had no effect.  
Also, this dialog looks different than the one that pops up when I use SocialMediaData, so I am not sure if SocialMediaData even uses this function. So, perhaps there is too much reverse engineering required altogether in this endeavor. But I thought I would give it a shot.

---

<div class="post-metadata">

**Author:** ![david3](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/david3/32/25830_2.png) [@david3](https://community.wolfram.com/u/david3)\
**Post date:** [October 17, 2014, 2:55am UTC](https://community.wolfram.com/t/authorizing-socialmediadata-through-jlink-or-custom-front-end/591/8 "2014-10-17T02:55:47Z")

</div>

Seems like someone would answer something this important.

---

<div class="post-metadata">

**Author:** ![david3](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/david3/32/25830_2.png) [@david3](https://community.wolfram.com/u/david3)\
**Post date:** [June 19, 2015, 6:34am UTC](https://community.wolfram.com/t/authorizing-socialmediadata-through-jlink-or-custom-front-end/591/9 "2015-06-19T06:34:16Z")

</div>

Crickets…
