TannerC

iOS - Can't auth via app, but can through website?

13 posts in this topic

This is a very strange problem that I haven't been able to find any answers to on Stackoverflow or the EN forums.

 

I have an iOS app that allows users to "share" to Evernote (amongst other services). It doesn't act like a true sync, the request is only made when the user actively presses a button to share with their Evernote profile.

 

If the user has the Evernote iOS application installed on their device, my app fails to authenticate. However, if the user does not have the app installed (and, instead, the authentication is requested via web form within the app), authentication and creation of a new note is done just fine.

 

Can you please help me? I'm going a little nuts over here with all of the user complaints.

 

UPDATE: Solution found below. It was a problem with the app's openURL check, conflicting with Dropbox.

1 person likes this

Share this post


Link to post

Hi,

 

Make sure you have followed all the steps in the ReadMe specifically this and this

Share this post


Link to post

Thanks Mustafa, I've followed those instructions and checked them repeatedly, to no avail. Any other ideas?

 

Is it possible I entered the wrong key? If so: is there any way to retrieve an existing key associated with my account?

Share this post


Link to post

Are you able to reproduce the issue or does it happen only for a few users?

Share this post


Link to post

I am able to cause the issue on my own devices, yes. Any user who has the Evernote app installed on their iPhone or iPad is also reporting the issue.

Share this post


Link to post

Can you send me a sample app that shows the problem? mustafa at evernote.

Share this post


Link to post

As an update: I confirmed that my key and secret are correct and now I'm getting a more unique error than I was before.

 

Specifically, in Xcode the error that's coming back from the Evernote server is: "Received error HTTP response code: 401" which makes me think the EVERNOTE_HOST is somehow set incorrectly.... but I have it set to "BootstrapServerBaseURLStringUS" which is set as "www.evernote.com" in the ENConstants.m file.

 

Any ideas? Anyone?

Share this post


Link to post

I just had a thought as to why it might fail with Evernote installed.

 

Disclaimer:I may be wildly off base as it's been a few months since I looked at the SDK so some of this is vague impressions from memory (normally I would take the time to check in person but am very busy for a couple of weeks). I don't like posting vague "try this" suggestions but this sounds like an important and frustrating bug so here goes:

 

I bet your app is only authorised for limited access.

 

If the Evernote client is installed, does authentication go via that app by default?

 

If so, is there an issue where the Evernote client is trying to get authentication, using your app's identifier, for access rights to which your app is not entitled?

Share this post


Link to post

I'll need a sample app to see what's going on. Without more information its hard to tell whats going on. Authentication with the Evernote for iOS app seems to be working in general.

Share this post


Link to post

Thanks for the input AndyDent, but according to the API documentation a request for bad permissions would yield a PERMISSION_DENIED error, which I'm not getting. Instead the Evernote app opens, the user is prompted to authenticate the app, the app returns and the logs show an error 404 page not found from the Evernote server.

 

Yet, if no Evernote app is installed the authentication works flawlessly through a UIWebView that the Evernote API pulls up.

 

Which makes me wonder if the problem somehow has something to do with how I'm setting the EvernoteSession.

 

Mustafa: would it be at all helpful for me to send you a promo code for the app in the App Store to try out?

Share this post


Link to post

Just incorporated the example authentication code from the Evernote docs and the error that is being reported makes me really think something's wrong with the URLs set for Evernote or something. The error in the logs was:

 

 

 

Error authenticating with Evernote Cloud API: Error Domain=com.evernote.sdk Code=-3000 "The operation couldn’t be completed. (com.evernote.sdk error -3000.)"

Share this post


Link to post

Whoa, so I experimented a bit with some settings and found the problem.

 

My app is creating sessions for both Dropbox and Evernote in the AppDelegate.m file. The problem, in this instance, was specifically under the app's openURL method, which was trying to confirm access to BOTH Evernote and Dropbox separately. When I combed them it works fine.

 

For reference, the code looks something like this:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url  sourceApplication:(NSString *)source annotation:(id)annotation {        if (&NSURLIsExcludedFromBackupKey == nil) {        return NO;    } else {        BOOL canHandle = NO;        if ([[NSString stringWithFormat:@"en-%@", [[EvernoteSession sharedSession] consumerKey]] isEqualToString:[url scheme]] == YES) {            canHandle = [[EvernoteSession sharedSession] canHandleOpenURL:url];        }                DBAccount *account = [[DBAccountManager sharedManager] handleOpenURL:url];        if (account && canHandle) {            DBFilesystem *filesystem = [[DBFilesystem alloc] initWithAccount:account];            [DBFilesystem setSharedFilesystem:filesystem];            NSLog(@"App linked successfully!");            return YES;        } else {            return NO;        }    }}
1 person likes this

Share this post


Link to post

Right, if you are using both, you need to combine both. Good to know your problem is solved. If you need to me to test it out, I'd be happy to.

Share this post


Link to post