"Access Token not found" when using Facebook SDK - facebook

I have a BlackBerry app which needs to post a message to a user's Facebook wall. I am using the Facebook BlackBerry SDK.
I have set up a simple test app which attempts to get the current user's details when a button is pressed by calling the following method:
private void postToFacebookWall(){
String NEXT_URL = "http://www.facebook.com/connect/login_success.html";
String APPLICATION_ID = "xxx"; //Removed for security
String APPLICATION_SECRET = "xxx"; //Removed for security
String[] PERMISSIONS = Facebook.Permissions.USER_DATA_PERMISSIONS;
ApplicationSettings as = new ApplicationSettings(NEXT_URL, APPLICATION_ID, APPLICATION_SECRET, PERMISSIONS);
Facebook fb = Facebook.getInstance(as);
try {
User user = fb.getCurrentUser();
Logger.log("User has authenticated app and logged in. Name: "+user.getName());
} catch (FacebookException e) {
Logger.log(e.getMessage());
}
}
Here's what happens when I click the button.
In the system log I receive an error message: Access Token not found.
Then the following login screen is shown:
Then I'm asked whether I would like to authenticate this app:
Clicking on 'Install' or 'Cancel' does nothing.
If I log into Facebook via the website and authenticate the app then I don't get the 'Access Token not found' error and everything works as expected.
How can I allow my Facebook app to be authenticated correctly to avoid the 'Access Token not found' error?

Actually any BB app with same approach can't authorize right now. It is FB issue, but no one is hurry to fix it.
Here is mine question:
Unable to pass FB OAuth for my application
Here is FB bug ticket:
https://developers.facebook.com/bugs/401534949883394?browse=search_4ffad6fdebcfa6990918340
Here is topic on dev forum:
http://supportforums.blackberry.com/t5/Java-Development/FaceBook-API-error-code-11-Method-Deprecated/m-p/1808833#M203977
I found workaround to pass it but it doesn't work for all OSes/devices. Use iPhone user agent "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16" and enable cookies in BrowserField.
Please mark FB issue as reproduced. So probably they will increase priority and fix it faster.
UPDATE: FB fixed the issue! Please verify!

Related

OAuth Login CONNECTIVITY_ISSUE Uber SDK

The email id linked with Uber is: fikarrnot28#gmail.com
After successfully logged into user account though the App using LoginManager, the error occurred.
This is the generated GET Request of login in the web view (I have found it when debugging the Uber SDK LoginActivity)...
https://auth.uber.com/login/?breeze_local_zone=sjc1&next_url=https%3A%2F%2Flogin.uber.com%2Foauth%2Fv2%2Fauthorize%3Fclient_id%3D_AZAHxnjsACGj4oNYtQmHT2BoxLoRslm%26redirect_uri%3Dhttps%253A%252F%252Fwww.fikarrnot.com%252FPrivacy-Policy%26response_type%3Dcode%26scope%3Dprofile%2Bhistory%2Brequest_receipt%2Brequest%2Ball_trips%26show_fb%3Dfalse%26signup_params%3DeyJyZWRpcmVjdF90b19sb2dpbiI6dHJ1ZX0%253D%250A&state=BpOm3pJ5GOScZSjle7l4hsCKCczTjYO2XvoV8e-RviI%3D
...with Headers...
[{"key":"X-Requested-With","value":"com.en****rs.fi****not.fi****not","description":""},{"key":"Cookie","value":"utag_main=v_id:01626ccd77e200225dc1cfc5c6c40009801c709000400$_sn:1$_ss:1$_st:1522245627690$ses_id:1522243827690%3Bexp-session$_pn:1%3Bexp-session$segment:a$optimizely_segment:b; _ga=GA1.2.14743532.1522243830; _gid=GA1.2.1008247445.1522243830; AMCVS_0FEC8C3E55DB4B027F000101%40AdobeOrg=1; aam_uuid=62184944397867583642625051211265352658; AMCV_0FEC8C3E55DB4B027F000101%40AdobeOrg=1611084164%7CMCMID%7C62681591052865814432656684984272277453%7CMCAAMLH-1522848630%7C3%7CMCAAMB-1522848630%7C6G1ynYcLPuiQxYZrsz_pkqfLG9yMXBpb2zX5dvJdYQJzPXImdj0y%7CMCOPTOUT-1522251030s%7CNONE%7CMCSYNCSOP%7C411-17626; AAMC_uber_0=AMSYNCSOP%7C411-17626; udid=w_2b967ea663b645cdbd69338871543566; arch-frontend:sess=BAqSPo47olILtPKNMYph-A.Js4qapThHROtKkyZNYsCJC8VwKDpejcPNcDzi8l_zuHUssy_5Xz_FO2swyc1v519menihaos4oCb4GpyKLIjclRD9LlQK79RvjhCnn-YCRHGEgIP3ZVwSLK10taTmHhsKhWPya-l7qA24XD3OlBcrXe6WfMdVQh7q00KJQMG0P4pvevBB-zSixSuMx4DmN9SsQ4JZSx-3jn2XvW8qO_S7-II8nebHXbCMz83acRilZUTw81aUU5dJhLR-Y38z9ZvkNyoGjpuInCguKYS_IOJMB5V1Vj7VC47F3N80lk4Fdl_i-IXpYw7uGCIvK_EhBX2QprbZlkPTvclJ1sBGVy9WG57MQ2P0mMh9JO6xMqqCX6TXoFVJMo3hGtjINXZmAxkh-Hs4l1QMheaJBxClGEmhwAbfOwwaFeGbKXfIRos9yqgC6cdB7CJDhNQmqabAVlzInp0zGnlxt9tPsInZF-jGhWJnbG9I3Z7qzrHpUoYHD7bsmaPfeyMpaywYbRu8KgTCN_iukWz5UOc7iGrzA1k-_QKNUF7IoCK9nMOK0EHcLwFoOHusoXWW8AlHUto28Hg0gEZYQWLW7s0TRq-XFwdt5MW5PuFtRDmU6QVt2E4QLfzghwvJvVGPrOvtyJbcEorVm9I0taYvYJgaLn9VFW7No4H_V9xz0CVRXT63fshZnUV_Ggx3s0N9eZToKnb_AC-l7HyxGb3mKXypLuNl7ZDQdz-ONRc8s7-7BiaCAGPjbUE1d_R5a6F4STBJyXoq4LENS9o8PdrumbhdCZvzk1aT3jdyTldlCi0chUmz8jP1FdQ6Yfdte2UYzHnGs8pKHcE4OZlepf-Jnb6PY2svG6TWJby9hbMq1XYwFgmUvcnJELk_WDLQW3lXsa9YnOnX5lZBqyIqxYhQQXEJTtxdmcJfE1pwzSOiXvlh6UIBs_2MVLRr3Dc8jhc5qp8YjgV2pYa.1522243813342.1209600000.MQ38q8xYZeHYu454GB5ZPUpQ-yvZ0ZsHya8VOcIFqOQ","description":""},{"key":"Host","value":"auth.uber.com","description":""},{"key":"Accept","value":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","description":""},{"key":"User-Agent","value":"Mozilla/5.0 (Linux; Android 7.0; SM-J701F Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/65.0.3325.109 Mobile Safari/537.36","description":""},{"key":"Upgrade-Insecure-Requests","value":"1","description":""},{"key":"Connection","value":"keep-alive","description":""},{"key":"Accept-Encoding","value":"gzip, deflate","description":""},{"key":"Accept-Language","value":"en-GB,en-US;q=0.9","description":""}]
The Response coming "Too many requests", after that onLoginError() called with CONNECTIVITY_ISSUE error.
Another thing is that, maximum time Uber SMS gateway is not working when I try to login (2 factor verification), thus OTP is not coming. I have also tried adding another developer in the developer dashboard, but They are also unable to get OTP when try to login.
Note 1 : The redirect url I am using in my app is exactly same as I am using in my developer dashboard.
Note 2 : Previously my code was working perfectly in the sandbox environment (with sample uber account), but now it is not working after I have changed to the new account. So, I suppose the code is not the problem.
Note 3 : The previous email id linked with this app for Uber was msayan64#gmail.com
Note 4 : The App is going to publish very soon, and it is using Uber as a value addition.
Questions:
Are there any changes required to my code?
Can using the sandbox mode be a problem?
If I need to give the App URI as the redirect URI, what should be the format (suppose the package name (App id) is com.example.app)?
When will be the SMS gateway work?

Facebook Login - Windows 10 UWP - Desktop

I am building a new Universal Windows 10 UWP App, and trying to do a Facebook login.
On Facebook, I have set the Windows App section of my app to have the identifier of my app:
Windows : s-1-15-xxxxxxxxxxxx
Windows Phone : fef49b712e5a843cbfeb0c9d780423fc (Not the actual one)
In the package manifest file, I have added the protocol of:
msft-fef49b712e5a843cbfeb0c9d780423fc
Which means I set my redirect_uri parameter to:
msft-fef49b712e5a843cbfeb0c9d780423fc://authorize
When running on a phone (with Windows 10 Mobile Preview) the service works fine, it opens up the Facebook app on the phone (using fbconnect://authorize?.....), which in turn authenticates, and then opens my app back up - perfect!!
However, when trying the same on the desktop it doesn't work. In my Launcher.LaunchUriAsync() is set to have a fallback Uri of the standard Facebook web dialog (https://www.facebook.com/dialog/oauth?.....) - This is because there is no Facebook app for Windows 10 that supports login.
Sending the same redirect_uri through to Facebook, it opens up the web browser (Edge) and asks for permissions etc. once the permissions have been given, nothing happens. It seems as though the protocol handling isn't working.
Any thoughts would be useful.
On desktop, try using the WebAuthenticationBroker instead of Launcher.LaunchUriAsync as described in this example: http://dotnetbyexample.blogspot.de/2015/06/custom-oauth-login-to-facebook-for.html
private async Task<string> AuthenticateFacebookAsync()
{
try
{
var fb = new FacebookClient();
var redirectUri =
WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();
var loginUri = fb.GetLoginUrl(new
{
client_id = AppId,
redirect_uri = redirectUri,
scope = ExtendedPermissions,
display = "popup",
response_type = "token"
});
var callbackUri = new Uri(redirectUri, UriKind.Absolute);
var authenticationResult =
await
WebAuthenticationBroker.AuthenticateAsync(
WebAuthenticationOptions.None,
loginUri, callbackUri);
return ParseAuthenticationResult(fb, authenticationResult);
}
catch (Exception ex)
{
return ex.Message;
}
}
Use WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri for redirect_uri.
And update the same uri in facebook developer console.
https://developers.facebook.com/apps//settings/
Facebook developer console

Post on facebook SDK WP8

(OAuthException - #200) (#200) The user hasn't authorized the application to perform this action when post on facebook by through winows phone 8 code:
dynamic fbPostTaskResult = await instance.PostTaskAsync("me/feed", postParams);
permessions add in session = await App.FacebookSessionClient.LoginAsync("user_about_me,read_stream,publish_actions");
Debug access token on facebook app display
App ID -- User ID -- Issued 1409307661 Expires 1414491661 Valid True Origin Mobile Web Faceweb Scopes : public_profile
Did you try adding the Permission called status_update?
Perfect sample would be this:
why does posting to facebook page yield "user hasn't authorized the application"
Which Facebook permissions allow for posting to a page wall (not profile wall)?

Firefox and Chrome gives "too many redirects" error on the following Facebook Connect implementation

// GET "giris-yap/facebook"
public function action_facebook_index()
{
$facebook = IoC::resolve('facebook-sdk');
$user = $facebook->getUser();
if($user)
{
$profile = $facebook->api('/me');
return View::make('home.login-facebook')
->with('message_area', null)
->with('username', $profile['username']);
}
else
{
return Redirect::to($facebook->getLoginUrl(array('next' => 'http://dugun.dev/giris-yap/facebook')));
}
}
// POST "giris-yap/facebook"
public function action_facebook_process()
{
$facebook = IoC::resolve('facebook-sdk');
$user = $facebook->getUser();
$profile = $facebook->api('/me');
$input = Input::all();
Auth::attempt(array('username' => $profile['username'], 'password' => $input['password']));
if(Auth::check())
return Redirect::to('account');
else
return View::make('home.login-facebook')
->with('message_area', 'Giriş denemesi başarısız.')
->with('username', $profile['username']);
}
The code above works flawlessly on my machine but my friend get's an error on both Chrome and Firefox.
Chrome: Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.
Firefox: Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
It happens on this line:
return Redirect::to($facebook->getLoginUrl(array('next' => 'http://dugun.dev/giris-yap/facebook')));
In theory; I redirect to Facebook, then Facebook redirects back to action_facebook_index(), and it repeats. However, Facebook should not be redirecting it. It should show user the form to give application permissions, then redirect back. That works normally on my personal computer, but my friend is having the issues above.
Is there anything I can do to solve it?
Probably won't fix it but you should separate some of the logic. The part that checks for a logged in Facebook user should be in a Route filter. Then remove the array passed as parameter to the getLoginUrl method (Facebook automatically redirects to the requesting page).
Also your friend might have cookies turned off?
The problem was Facebook Application being in Sanbox mode, so only as the application owner, I had access to the required API's. If someone else made the request, Facebook redirected them back and hence creating an infinite loop.
The issue was solved by closing Sandbox mode on Facebook Application Settings and giving appropriate permissions.

Send Facebook apprequest from Windows Phone

I'm trying to send an apprequest from my Windows Phone 7.5 application to a Facebook friend to invite that friend to play a gameround.
According to Facebooks official documentation, a request should be performed via dialogs:
https://developers.facebook.com/docs/reference/dialogs/requests/
Unfortunately I cannot get this to work/show on Windows Phone.
Is there another way to send an apprequest to a known facebook user (I only need to send it to one user)?
I have tested to do it by invoking the following code:
FacebookClient fb = new FacebookClient(_appAccessTooken);
var arguments = new Dictionary<string, object>();
arguments["appId"] = Consts.FaceBookAppID;
arguments["title"] = "Play a gameround!";
arguments["message"] = "Would you like to play with me?";
fb.PostAsync("/user-id/apprequests", arguments);
This works, but:
1) The user will not get a proper notification, it will only be visible from the Applicationcenter notices.
2) The request will be sent from the application name, not from me (the user)
Does anybody know how to get this working?
II'm using the Facebook SDK for .NET (http://facebooksdk.net/)
Thanks in advance.