/SafariOauthLogin

SFSafariViewController and OAuth: an example with Instagram

Primary LanguageSwiftMIT LicenseMIT

SafariOauthLogin

SFSafariViewController and OAuth: a simple login example with Instagram on iOS, written in Swift 2

The 3-steps install

let INSTAGRAM_CLIENT_ID = ""
let INSTAGRAM_CLIENT_SECRET = ""
let INSTAGRAM_REDIRECT_URL = ""  // example: SafariOauthLogin:// or http://strawberrycode.com

And add your redirect URI to info.plist

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>com.strawberrycode.SafariOauthLogin</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>PLACE_APP_NAME_HERE</string> // example: SafariOauthLogin
        </array>
    </dict>
</array>

Use the app name set in your project, for example: SafariOauthLogin

###Note:### INSTAGRAM_REDIRECT_URL is one of the URIs you put in the field Valid redirect URIs in the Instagram Developer Portal when you create a new Client ID. It can be a website URL or an app scheme like SafariOauthLogin://. If you want the login to redirect to your app, then put the app scheme there.

Compatibility

min: iOS 9 - Xcode 7 beta 4

More about this project

Read the article: SFSafariViewController and OAuth – the Instagram example

That's all folks!

Happy coding :)