I've successfully set up the "DemoApp" project from the Facebook IOS SDK to use my "OKC ThunderCast" Facebook application. I have also configured another "Tester" application from scratch to successfully use the Facebook SDK and publish stories to my news feed. However, in my production application, I always get this result when calling the "dialog" method. The full description of the error message is "Error on line 52 at column 17: Opening and ending tag mismatch: div line 0 and body"
Here's a detailed walkthrough of all of my code to make sure nothing is missed.
1) A UIViewController calls the "authorize" method
NSArray *fbPerms = [NSArray arrayWithObjects:#"read_stream", #"offline_access", nil];
[[FacebookSingleton sharedInstance].facebook authorize:fbPerms delegate:self];
Note: The FacebookSingleton is a class I wrote that always returns a single instance of the "Facebook" class. I am using it successfully in other applications.
2) Safari is opened and the user is successfully authenticated and authorized
3) The application is called back and the "handleOpenUrl" method is called, which calls the "fbDidLogin" method of the UIViewController
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
Facebook *fb = [FacebookSingleton sharedInstance].facebook;
return [fb handleOpenURL:url];
}
4) The same UIViewController handles the "fbDidLogin" event, and calls the "dialog" method
- (void)fbDidLogin
{
[[FacebookSingleton sharedInstance].facebook dialog:#"feed" andDelegate:self];
}
I also have the necessary "URL Schemes" and "URL Types" entries in the .plist file. To my eyes, I am using exactly the same code in the "DemoApp", "Tester", and production applications. But while the DemoApp and Tester work, I always see this HTML error in the feed dialog in my production application. Has anyone seen a similar issue? Could it be related to the Facebook "Bundle ID" setting in the Facebook application settings? Is there some build or .plist setting that is different?
I have invested a great deal of time into troubleshooting with no success in several weeks. Thanks in advance...
The cause of the problem was setting a value to the key "User-Agent" in the NSUserDefaults dictionary. I wanted to specify my own User-Agent to uniquely identify my iOS app. But somehow setting this value caused the problem above. When I simply renamed this key to "OKCTC-User-Agent" the error was immediately resolved.
I did log an issue on the GitHub site for the Facebook-IOS-SDK. Hopefully this will help others who have encountered similar problems.
Related
I'm using the iOS LinkedIn SDK to log into my App and retrieve basic profiles.
All works perfectly fine the first time I login, until either I log out, or I close my App.
On attempting to log back into my App with LinkedIn: the usual redirect to the LinkedIn app takes place, but the permissions screen for my app doesn't pop up, it just redirects straight back to my app with the following error:
Error Domain=LISDKAuthError Code=5 "(null)" UserInfo={errorDescription=The operation couldn’t be completed. Software caused connection abort, originalDomain=LISDKServerError, errorInfo=PARSING_ERROR}
I can only successfully log back in again if I first close the LinkedIn App, before reopening mine.
Does anyone have an idea of what's going on please?
-This doesn't occur on all of my test devices!
-On the device that it does occur on, I also receive the same error in that scenario when running the sample App provided with the LinkedIn SDK.
-The LinkedIn App is up to date.
-The App id, bundle ids etc etc are all set, hence login success half of the time!
-I've tried calling [LISDKSessionManager clearSession] in numerous locations.
Cheeky framework fix alert.
Uncomment out the lines in LISDKSession.h
This allows the correct use of [LISDKSessionManager hasValidSession]
Which is an improvement on what we were working with.
Not yet tested with iOS12...
I had a similar problem. It was mainly reproduced only on iOS 12. The problem is that when you already have a LinkedIn application running, you will not be able to log in through their SDK in your application. On iOS 11, the second time you try to log in after this error, the authorization worked fine.
I solved this issue by simply showing the user an alert with a message about what he needs to do to authorize.
Here you can check an example of my implementation in Swift 4:
LISDKSessionManager.createSession(withAuth: ["r_basicprofile"],
state: nil,
showGoToAppStoreDialog: true,
successBlock: { _ in
// Your actions in case of successful authorization
}, errorBlock: { error in
guard let nsError = error as NSError? else {
return
}
if #available(iOS 12.0, *),
nsError.code == LISDKErrorCode.SERVER_ERROR.rawValue {
// Show alert to user with text - "Please, shut down the LinkedIn app and try login again"
} else if nsError.code != LISDKErrorCode.USER_CANCELLED.rawValue {
// Handling when user tap on Cancel button in LinkedIn SDK
}
})
I've been battling for a fix for this with LinkedIn for months.
There 'solution' is to kill off the SDK.
Taken from their 'Important updates to the LinkedIn Developers program and APIs' email December 2018:
"Authentication, SDKs, and Plugins: We are also deprecating several obsolete or seldomly-used products and technologies."
"SDKs: Our JavaScript and Mobile Software Development Kits (SDKs) will stop working. Developers will need to migrate to using OAuth 2.0 directly from their apps."
Uncomment this two lines of code in LISDKSession.h
- (LISDKAccessToken *)getAccessToken;
- (void)setAccessToken:(LISDKAccessToken *)accessToken;
Currently I have a Twitter login that authenticates the user just fine, receiving all the appropriate information for the user necessary for confirming a complete login.
I then am calling the [PFTwitterUtils logInWithBlock:...] method in order to authenticate the user through Parse and populate a new user in _User.
(I am not using just this method to present the Twitter login dialog box as I could not get it to present itself).
Here is the strange part:
On the first time I launch the app, I sign in with Twitter, and then call the logInWithBlock method and receive the following error:
Something went wrong: The operation couldn’t be completed. (NSURLErrorDomain error -1012.)
The strange part is that this issue does not occur at all if I relaunch the app again. The only difference is that upon relaunch I believe the Twitter Account information that I had used before (via browser not accounts) is saved on the device. When I launch the app again, I have it set so that it reloads the previous session: this time the [PFTwitterUtils logInWithBlock:...] works like a charm, creates a new user, etc., without any issue.
NOTE: I have a valid URL saved as the Callback URL on my Twitter App's settings. Also, I hope it is clear that the setup was done correctly given that it works fine on second log in.
Here is the login code I am using:
// Login with Twitter through Parse
[PFTwitterUtils logInWithBlock:^(PFUser *user, NSError *error) {
if (error != nil) {
// Something went wrong
NSLog(#"Something went wrong: %#", [error localizedDescription]);
breakLogin = YES;
[self invalidateSignInTimer];
return;
}
else if (user.isNew){
userObjectID = user.objectId;
[user saveInBackground];
NSLog(#"New User");
}
else if (!user.isNew) {
userObjectID = user.objectId;
[user saveInBackground];
NSLog(#"Returning User. Welcome Back!");
}
}];
I am running out of patience and ideas on why this is happening. If anyone has any ideas please let me know - thanks!
UPDATE:
I noticed that the reason this seems to be happening is such:
The first time i attempt to login there is no PFUser, whereas the second time there seems to be a saved [PFUser currentUser], which allows the [PFTwitterUtils...] method to log in and create the new user.
Yet I am still not sure how to prevent the failure the first time without manually creating a new PFUser and then logging in with Twitter, then PFTwitterUtils...
UPDATE 2
I have resolved this issue with the answer I have provided below. I am leaving this up as I feel this is something that may help others out there in the future.
So after extraneous research, I seemed to have found a solution.
First I made sure that all of my framework files (SKDs, headers, etc) were up to date by removing all of their references from both the project and the library linking.
Second I made sure that all keys and secrets were remade and updated in my
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
Lastly I made double checked that I properly went through the set up for Twitter authentication through Parse's website.
BUT what I found to be the only solution rested in the Callback URL.
When specifying the Callback URL in your Twitter Application under "Settings", I had to uncheck the Lock Callback URL option, despite the recommendation by Twitter. (seen below)
I was a little unhappy that all of this trouble derived from something so mundane, however I was at least pleased that solution was in fact resolved without too much trouble. Hopefully this answer helps someone out there struggling with a similar issue.
I am implementing iOS app where I have to implement Respoke SDK for audio and video calling. Audio and video functionality is working fine in development mode but In production mode it gives me error "Api authentication error". I have used this code for production:
[self.client connectWithTokenID:[[aryResult valueForKey:#"data"]valueForKey:#"token"] initialPresence:nil errorHandler:^(NSString *errorMessage)
{
[self showError:errorMessage];
}];
For reference, I have used this : Respoke Documentation
Please tell me what is missing in my end. Please help me out.
Thanks a lot in advance!
It seems most likely you are having one of these problems:
The value returned by [[aryResult
valueForKey:#"data"]valueForKey:#"token"] is not exactly the same
as the value returned by the Respoke server when asking for a
brokered authentication token from
https://api.respoke.io/v1/tokens due to URL encoding of the data
between the server and your iOS application or something similar.
The brokered authentication token is only valid for 20 seconds, so
perhaps too much time has passed before your iOS application
attempts to use it.
You have not switched your application out of
development mode on the Respoke developer portal, or have not
created a role to use when authenticating. This documentation
page
explains how to properly set up your application and define a role
for using brokered authentication. You can also use the example code
on that page to make sure that you are getting a valid token for
your application. This would help make sure you have your account
configured correctly.
I have resolved the issue by adding some lines of code. Now for the production mode, code will be this:
if (!sharedRespokeClient)
{
// Create a Respoke client instance to be used for the duration of the application
sharedRespokeClient = [[Respoke sharedInstance] createClient];
}
sharedRespokeClient.delegate = self;
[sharedRespokeClient connectWithTokenID:tokenStringFromServer initialPresence:nil errorHandler:^(NSString *errorMessage) {
[self showError:errorMessage];
}];
I've got a server that interacts with Google Calendar on behalf of user. To do this it should obtain one-time access token from iOS application. I've referred to documentation, but have some issues with sign in.
I have started from "SignIn" example app (pod test Google > Sign In), provided it with my credentials (GoogleServices-Info.plist, bundleId). Then I signed it with my provision and started on iPhone 6, everything works like a charm.
Then I have added
[GIDSignIn sharedInstance].serverClientID = #"<my-server-client-id>";
in ViewController:viewDidLoad. I have unauthorised in app, launched it again. It opened auth screen (youtube.app, 10.31.11670) again, I selected the same account, but this time it launched my app without displaying permissions screen, -signIn:didSignInForUser:withError: method was called, but GIDGoogleUser was nil. Error stated
Error Domain=com.google.GIDSignIn Code=-1 "A potentially recoverable error occured. You may try again." UserInfo=0x17026af80 {NSLocalizedDescription=A potentially recoverable error occured. You may try again.}
I have tried several times, but each time I have received the same result. But if I comment ...serverClientID... it begins to work again.
Then I have launched this app in simulator and it authorised successfully using WebView and I received user.serverAuthCode.
I decided that problem was in YouTube.app, I uninstalled it from device, but the same problem happened with other Google applications.
Could you point me what is wrong with my singIn implementation?
PS
Finally I decided to use workaround and rewrote -canOpenUrl: in UIApplication subclass this way:
- (BOOL)canOpenURL:(NSURL *)url
{
if ([[url scheme] hasPrefix:#"com-google-gidconsent"] || [[url scheme] hasPrefix:#"com.google.gppconsent"]) {
return NO;
}
return [super canOpenURL:url];
}
And now it uses WebView authorisation and I can receive my one-time token. But this approach is crappy of course.
I am running the Facebook SDK 3.1 on Xcode 4.5GM with iOS6 simulator. I connect to FB in the iOS settings and successfully FB connect in my app using the new iOS6 FBConnect UI. I have an access token, can see my friends, send app requests, post to my wall, etc. However, every time I initiate any sort of FBURLConnection is made, I see this printed to my console:
Error: HTTP status code: 400
I went into the FB code and printed the reponse when this error is printed and I get:
{
body = {
error = {
code = 100;
message = "(#100) The parameter 'attribution' is required for the 'mobile_app_install' activity";
type = OAuthException;
};
};
code = 400;
}
Does anyone know how to resolve this? All functionality seems to work, but I keep seeing this spam my console.
Right after the session is created do this:
[FBSession setActiveSession:session];
As best as I can tell, this is a bug introduced in the 3.1 SDK. Looking at the network traffic with Charles, they’re trying to POST to graph.facebook.com/[user id]/activities but it’s failing.
After much troubleshooting and looking at all the suggestions on Stackoverflow, I got this error 400 (error.code = 5) thing resolved.
The solution in my case was to make sure the params (aka postParams) included in my startWithGraphPath call had exactly the params supported by the type of content being posted.
More specifically, I was posting a link to me/feed with the #"ref" key (typically used for tracking with FB Insights).
After removing the #"ref" key, startWithGraphPath succeeded.
NSMutableDictionary *postParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Test NAME field (from ios app)", #"name",
#"Test caption", #"caption",
#"Test description", #"description",
#"http://example.com/test1.html", #"link",
#"http://example.com/water.jpg", #"picture",
// #"foo", #"ref", // WRONG!
nil];
[FBRequestConnection startWithGraphPath:#"me/feed"
parameters:postParams
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
My activeSession (and all other possible culprits) checked-out OK.
This is the same as my answer from here: Facebook SDK 3.1 - Error: HTTP status code: 400
But it could help people still getting the 400 error.
The original issue was resolved by Facebook just after the 3.1 SDK was released.
But some are still having issues, if you have this issue you should check the login flow, and look at facebooks examples, if you are still having issues this could be a hint to a solution.
I got the 400 error when I do not have authorization to get to my information. The strange thing is that I get an accessToken and even a valid login (this is because I structured my code, with the help according to Scrumptious example and I did a valid login when the Session state is open).
The FBSessionState is only opened for like a second and then it changes to closed with an 400 Error.
With iOS6 native login you get the permission alert when you ask for it, and then the phone remember that choice for 24 hours. But if the user logs in to the facebook home-page and then deletes permission for the application the phone will remember that setting for 24 hours, regardless if you re-install the app or not.
This I found out after some hours of debugging, since I allowed the application from the Settings in iOS, but I could not post, and since I deleted the permission from the facebook privacy, and the alert would not show again there was nothing I could do but to manually give me permissions via a debug tool or wait 24 hours so I could accept the facebook-permission alert again.
I discovered that Status Code 400 is also thrown with FBErrorHTTPError when something go wrong with Optional Properties in Define Action Type fieldset, within the Facebook=>Open Graph definition panel.
In my case I was posting an action object without a property marked as isRequired. Be also aware for isArray option and in general, for right matching with what you're sending.
This error reflected a bug on the server, which was fixed shortly after the 3.1 release was published. At this point there should be no more failures coming from this request. Hope this helps!