Hi,
I tried to connect to FaceBook Account and I am able to connect and seeing my picture and details. But when i tried to update the status I am getting 403 forbidden error.
Can anyone help me to resolve this?
Hi,
I tried to connect to FaceBook Account and I am able to connect and seeing my picture and details. But when i tried to update the status I am getting 403 forbidden error.
Can anyone help me to resolve this?
Thanks,
K. Siva Prasad Reddy
What means are you using to get a Facebook access token? Using the <fb:login-button> or are you using the OAuth 2 web server profile?
In either event, when your application requests authorization from Facebook, have you requested "publish_stream" permissions in the scope parameter? If you're using the <fb:login-button>, you'll need to be sure to pass "publish_stream" in the perms attribute. If you're using the OAuth 2 web server profile, then be sure to pass it as the value of the scope parameter sent to the authorization URL.
If you've done that and still can't post, give more details on how you're obtaining the access token and I'll see if I can spot the problem.
Craig Walls
Spring Social Project Lead
Hi,
I am using oAuth for getting access token.
Where should i pass the "publish_stream" perms attribute?Code:String fb_oath_uri = "https://graph.facebook.com/oauth/"; public String fbLoginAuthenticate() { return "redirect:"+ fb_oath_uri +"authorize?" + "client_id=" + clientId + "&display=page&redirect_uri=" + redirectURI; } private String assembleAuthentication(String authCode) { return fb_oath_uri + "access_token?" + "client_id=" + clientId + "&redirect_uri=" + redirectURI + "&client_secret="+ secret + "&code="+authCode; } public String retrieveAccessToken(String code){ String accessToken = null; if (null != code) { String authURL = assembleAuthentication(code); URL uri = null; try { uri = new URL(authURL); String result = crawlToURL(uri); String[] values = result.split("&"); for (String value : values) { String[] valuePair = value.split("="); if (valuePair.length != 2) { throw new RuntimeException("Unexpected auth response"); } else { if (valuePair[0].equals("access_token")) { accessToken = valuePair[1]; } } } } catch (MalformedURLException e) { throw new RuntimeException(e); } } return accessToken; } private String crawlToURL(URL uri) { ByteArrayOutputStream byteOutputStream = null; InputStream inputStream = null; String stream = null; try { inputStream = uri.openStream(); byteOutputStream = new ByteArrayOutputStream(); int i; while ((i = inputStream.read()) != -1) { byteOutputStream.write(i); } stream = new String(byteOutputStream.toByteArray()); } catch (IOException e) { throw new RuntimeException(e); }finally { if (null != byteOutputStream) { try { byteOutputStream.close(); } catch (IOException e) { //do some logging here instead of printStackTrace() e.printStackTrace(); } } if (null != inputStream) { try { inputStream.close(); } catch (IOException e) { //do some logging here instead of printStackTrace() e.printStackTrace(); } } } return stream; }
Thanks,
K. Siva Prasad Reddy
In your fbLoginAuthenticate() method, as a scope parameter to the authorization URL...something like this:
Note that the scope parameter takes a comma-delimited list, so you can ask permission for a variety of different things. See http://developers.facebook.com/docs/...on/permissions for details on what kinds of permission you may ask for from Facebook.Code:public String fbLoginAuthenticate() { return "redirect:"+ fb_oath_uri +"authorize?" + "client_id=" + clientId + "&display=page&redirect_uri=" + redirectURI + "&scope=publish_stream"; }
Craig Walls
Spring Social Project Lead
Wow..Its working now.
Thanks a lot :-)
Thanks,
K. Siva Prasad Reddy
hi,
where are you getting this value "&code="+authCode?
Thanks,
Gerald
Could you please share the code on how you made this working?
Thanks,