iOS linkedin authentication

后端 未结 6 1300
走了就别回头了
走了就别回头了 2020-11-29 05:45

I started developing an app for iOS in Swift. Now I am at the part where I need to create a login system. However we need the LinkedIn information from people.

How c

6条回答
  •  青春惊慌失措
    2020-11-29 06:10

    LinkedIn is an interesting beast, since their mobile SDKs have two flaws:

    • An end user NEEDS the LinkedIn app to be installed, otherwise the "login" button will redirect the user to the App Store.
    • The mobile access token cannot be used on the server. See this screenshot from LinkedIn's iOS documentation

    So while JAL's answer is sufficient, you may want to look into implementing LinkedIn's authorization_code OAuth flow in your mobile app instead of the LinkedIn SDK. This would look roughly like the following flow:

    1. The app will redirect the user to your webserver.
    2. The webserver begins the LinkedIn authentication flow, and redirects the user to LinkedIn.
    3. The user logs into LinkedIn, and gets redirected back to your webserver.
    4. The webserver reads the response, and exchanges the Authorization Code with LinkedIn for an access token.
    5. The webserver redirects your user back to the app, using a custom url scheme to send it the LinkedIn access token.
    6. The app uses the LinkedIn access token to login to Stormpath.

    Sound complicated? It's actually more straightforward than it seems. I actually wrote some demo code for this flow using Express.js & Swift. This example ultimately sends the access token to Stormpath to ultimately authenticate the user, but you can always replace it with your own code that calls the LinkedIn REST API to grab the profile's information.

提交回复
热议问题