Using LinkedIn's iOS 9 SDK for authentication with a webview instead of LinkedIn's mobile app - ios

My iOS app currently offers users the option to log in and sign up with their LinkedIn accounts. I am using this project for the LinkedIn log and OAuth: LinkedInOAuth
With the update to iOS 9, my app now occasionally crashes, when a user attempts to log in through LinkedIn using that project, with a runtime exception of WebThread(18): EXC_BAD_ACCESS(code=1, address=0x8)
To resolve this occasional crash, I turned to an updated version of the project I was using that conforms to ios 9 and linkedin's ios 9 SDK.
The issue is that while this new project has solved the WebThread crashing, it now requires users to download LinkedIn's app (if they don't have it) in order to log in to my app with LinkedIn.
The previous project never had such requirements and would present a webview that allowed anyone with a linkedin account to log in.
My question is am I wondering if it is possible to authenticate with LinkedIn in ios 9 without requiring the user to download the mobile app? My hopes are that it is possible to update the old project to conform to ios 9 while simply presenting a webvew. Thank you!

We only discussed this last week (at the time your question didn't have an answer, but happy to update you now—that is, if you haven't solved this in the meantime).
After scouring several sources I came across this:
Mobile vs server-side access tokens
Presently, there is no mechanism available to exchange them. If you
require tokens that can be used in both the mobile and server-side
environment, you will need to implement a traditional OAuth 2.0
solution within your iOS environment to acquire tokens that can be
leveraged in both situations.
from: https://developer.linkedin.com/docs/ios-sdk-auth
The premise being that via mobile solutions, they offer single sign-on thru their app. This works, but requires their app. Apple's approval process has swung both ways on this, and it appears that it is a flip of the coin as to whether they will allow this or not (the requirement of a third party app). #AroundThen didn't have any luck and his app was rejected due to the requirement, however, other users* have indicated Apple weren't adverse to it in their application processes.
Alternatively, their is the web logon process using OAuth2. This is pretty stock for their non-mobile solutions. Currently sharing the tokens between mobile and web solutions is not a default and if you want to share the same token their solution is that that is listed above.
In essence (and copied from my other answer here):
You can test for the presence of the linked-in app:
if it is not there: implement OAuth2 directly through your app
if it is there: use it or your OAuth2 implementation (which you'd probably err on the side of using their app for the link-ability between any features of the app you may need in yours).
Thereby avoiding the REQUIREMENT to have the app installed, but utilising it if it is.
This suggests that authentication away from the app is supported.
Reportedly, #AroundThen has had success with this process.
Good luck!
*1 I'm currently having trouble finding his post, but basically he provided login credentials that Apple attempted to use, but had locality issues and hence couldn't get in, but it was inferred they may have approved it if they had of.

Related

How to authenticate using the installed Twitter app

If the user is logged-in with the native Twitter app installed, I want my app to open the Twitter app to request authorization.
I already implemented the flow to get the oauth_token in order to start the login process through Twitter's api. Only, the current API Documentation do not mention anything about how to use the native iOS app in the process. It only sends back a url for the user to log in.
let url = URL(string: "https://api.twitter.com/oauth/authorize?oauth_token=\(result.oauthToken)")!
DispatchQueue.main.async {
UIApplication.shared.open(url)
}
On getting the requested oauth_token, I get this link. Opening the link will display a Webview to login. Not the native Twitter iOS app.
I tried to use a deeplink to manually launch the Twitter app, but I couldn't found any resources on how to setup the link properly.
So far I have tried things like:
twitterauth://authorize?consumer_key=[KEY]&consumer_secret=[SECRET]&oauth_callback=swifter-[KEY]
or
twitterauth://authorize?oauth_token=\(result.oauthToken)
without any success...
As mentioned in another post, Clubhouse has implemented exactly this flow. So it is possible. The question is how ? 😅
This flow seems to have not been officially supported since the retirement of TwitterKit on May 1, 2018. Any applications that still offer this functionality to their end users likely have some sort of partnership with Twitter to allow for this which is otherwise undocumented publicly.
The reasoning for this was detailed sparsely in a related Twitter Developer Forums thread:
Unfortunately at this time we have had to make some incremental adjustments that are not so smooth for everyone; especially as you’ve found, for mobile app developers. We’re in the middle of a transition to a new API platform (via Twitter Developer Labs) and there will be some changes as we go along - we are asking for your feedback to help us, and if you check the ideas, authentication and authorization is something we’ve heard a lot about.
I cannot tell you today exactly when we’ll get to an enhanced solution, but this is something we are actively working on.
Direct link
The official guidance is to use the traditional WebView method until Twitter officially re-releases this capability:
I don’t believe that this is possible any longer, so I would encourage you to use the full OAuth flow. I apologise that this may not be what your users prefer, but this is the documented way to gain authorisation (we do not document or support URL schemes for the native iOS app).
Direct link
We do not support or document any means of users signing in to Twitter outside of the OAuth flow; any use of undocumented features is subject to change without notice.
Direct link
As linked above Twitter appears to be soliciting feedback on this via their UserVoice page, should you feel so inclined to suggest the re-implementation of such a feature.

Single Sign On authentication in IOS requires LinkedIn App

We've migrated to the latest LinkedIn IOS SDK which only supports single sign-on (SSO) authentication, in conjunction with the official LinkedIn mobile application. Our app works really well with this, however Apple will not approve our latest version, because it requires the LinkedIn app to be installed for the authentication to work.
We need a solution which handles the scenario when the LinkedIn app is not present, to use web authentication, however LinkedIn are very specific stating Mobile SDK-enabled applications require the official LinkedIn iOS app to be installed on the device to function properly" https://developer.linkedin.com/docs/ios-sdk - The Mobile SDK was released in July, so presume we are not alone in having our app rejected by Apple approvals.
Could you test for the presence of the linked-in app:
if it is not there: implement OAuth2 directly through your app
if it is there: use it or your OAuth2 implementation (which you'd probably err on the side of using their app for the link-ability between any features of the app you may need in yours).
Thereby avoiding the REQUIREMENT to have the app installed.
Researching for this I did find:
Mobile vs server-side access tokens
Presently, there is no mechanism available to exchange them. If you
require tokens that can be used in both the mobile and server-side
environment, you will need to implement a traditional OAuth 2.0
solution within your iOS environment to acquire tokens that can be
leveraged in both situations.
from: https://developer.linkedin.com/docs/ios-sdk-auth
which suggests that authentication away from the app is supported.
Pleased to confirm that the solution kindly suggested by Madivad of using the new LinkedIn SDK if the LinkedIn app is installed and when it's not reverting to traditional OAuth 2.0 works fine. Apple are also back on our Christmas card list as they approved this latest version today within 40 minutes of submission:) Thanks Madivad for helping out with this.

Swift 2 OAuth2 LinkedIn connection

I'm gonna make an native iOS app with Swift 2 and Xcode 7. The users should login using LinkedIn and OAuth 2 but I'm wondering how I should begin to set this up. I don't have many experience with OAuth 2.
Is there a good tutorial or a sample app? I saw the Ray Wenderlich post but that comes with an existing project. I want to build an app with LinkedIn login from scratch.
EDIT
I want to use the LinkedIn login to get the user's connections and send them notifications. I was researching this and I found some pages that said that connections can't be retrieved from the new LinkedIn API, is this true? It is not possible to get someone's connections from LinkedIn in a native iOS applications?
You should start with LinkedIn guide for LinkedIn and OAuth 2 .
But still if you need a sample for Authentication with OAuth 2 here it is .
For your second question related to the connection yes Linked have made changes but the API is still available but for the partners .
If you are an existing LinkedIn partner, these changes will not impact your existing partnership or the associated APIs that your partnership allows you to access.
If you are experiencing issues as a result of the May 12th changes, please reach out to your LinkedIn Business Development representative immediately.
For further details you can see Developer Program Transition Guide.
Check out this repo, I did this swift pre-2.0 but it shows you the basic algorithm. You can do it the with your secret hard coded or fetch it from the server. The key is getting the oath header just right which is a huge pain
https://github.com/GregPrice24/SwiftStream
Check this out: https://github.com/jeyben/IOSLinkedInAPI
I used this repo and successfully implement LinkedIn integration in my App. It is in Objective-C but you can use Cocoapods and import them as Frameworks and use in swift2 with no trouble.
Note: As of the 12´ May 2015 LinkedIn applied restrictions to API usage for all non partners: See: https://developer.linkedin.com/blog/posts/2015/developer-program-changes
So you can only get the basicprofile at the beginning, but you can apply for the partner program to get those extra information such as connections here: https://developer.linkedin.com/partner-programs

Google Plus Over the Air installs via server-side oauth

Google released nice feature called Over-The-Air Installs. But documentation has example only for google's sign-in button.
Checked Google API PHP Client and it doesn't have anything related. Tried adding apppackagename and app_package_name to authorization url - didn't help. Another problem is that Google doesn't enable this feature for all clients.
Is it possible to use it via oauth triggered on server-side? Does Google somehow indicate that you're allowed to use this feature?
It is currently not possible to trigger Over-The-Air Installs using the server-side flow. It is recommended that you use the client-server flow as described and demonstrated in the quick-start sample apps instead of using a server-side flow.
You can direct users to install the app at the conclusion of your install by linking to your app in the play store. From the play store, the user could still install your app directly to their device, it would just not happen in the sign-in dialog.
Even hybrid client-server flow needs to implement the "sign-in button" to your page...
https://developers.google.com/+/web/signin/server-side-flow
https://developers.google.com/+/web/signin/client-to-server-flow
Don't know why Google is doing this way!

The app must ask for a basic read permission at install time. Only on native?

I've been using the Facebook iOS SDK for some app I've been working on -
My app only requires publishing of a photo, and I have no use of any read permissions or basic info.
When logging in using a browser (Simulator) or Fast-App switching (Device) it works fine with just openActiveSessionWithPublishPermissions:#[#"publish_stream"]...
But if I would try the same with an iOS6 device with the Native login, it would show the error describe in the title. Even though I have no need for any read access. This problem only occurs in the native login, and not in the Browser-based or Fast-App switching based logins for some reason.
Any ideas?
I reckon it has something to do with this:
Asking for Read & Write Permissions Separately
You are now required to request read and publish permission separately (and in that order). Most likely, you will request the read permissions for personalization when the app starts and the user first logs in. Later, if appropriate, your app can request publish permissions when it intends to post data to Facebook.
You cannot request read and publish permissions simultaneously using iOS6's Facebook support, and if you attempt to, the SDK will take the user through a less-optimal app-switching or web-based authentication flow.
It seems that they added this in SDK 3.1.

Resources