InstagramLogin allows iOS developers to authenticate users by their Instagram accounts.

Overview

InstagramLogin

CI Status License Platform Version Carthage compatible codebeat badge

InstagramLogin allows iOS developers to authenticate users by their Instagram accounts.

InstagramLogin handles all the Instagram authentication process by showing a custom UIViewController with the login page and returning an access token that can be used to request data from Instagram.

Inspired by projects like InstagramAuthViewController and InstagramSimpleOAuth, because of the need for a simple and easy way to authenticate Instagram users.

InstagramLogin Demo (GIF)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Second, go to your Instagram's developer portal, click on Manage your client, and uncheck the option "Disable implicit OAuth" from the Security tab.

Third, edit the Constants.swift file with your client info from Instagram's developer portal:

" static let redirectUri = "" ">
static let clientId = ""
static let redirectUri = ""

Fourth, go ahead and test it! 🚀

Requirements

  • iOS 9.0+
  • Xcode 9.0+
  • Swift 4.0+

Installation

CocoaPods

InstagramLogin is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'InstagramLogin'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

To integrate InstagramLogin into your Xcode project using Carthage, specify it in your Cartfile:

github "AnderGoig/InstagramLogin"

Follow the detailed guidelines here.

Manual installation

Simply copy all the Swift files from the InstagramLogin/Classes folder into your Xcode project.

Usage

First of all, go to your Instagram's developer portal, click on Manage your client, and uncheck the option "Disable implicit OAuth" from the Security tab.

" let redirectUri = "" func loginWithInstagram() { // 2. Initialize your 'InstagramLoginViewController' and set your 'ViewController' to delegate it instagramLogin = InstagramLoginViewController(clientId: clientId, redirectUri: redirectUri) instagramLogin.delegate = self // 3. Customize it instagramLogin.scopes = [.basic, .publicContent] // [.basic] by default; [.all] to set all permissions instagramLogin.title = "Instagram" // If you don't specify it, the website title will be showed instagramLogin.progressViewTintColor = .blue // #E1306C by default // If you want a .stop (or other) UIBarButtonItem on the left of the view controller instagramLogin.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .stop, target: self, action: #selector(dismissLoginViewController)) // You could also add a refresh UIBarButtonItem on the right instagramLogin.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .refresh, target: self, action: #selector(refreshPage)) // 4. Present it inside a UINavigationController (for example) present(UINavigationController(rootViewController: instagramLogin), animated: true) } @objc func dismissLoginViewController() { instagramLogin.dismiss(animated: true) } @objc func refreshPage() { instagramLogin.reloadPage() } // ... } // MARK: - InstagramLoginViewControllerDelegate extension YourViewController: InstagramLoginViewControllerDelegate { func instagramLoginDidFinish(accessToken: String?, error: InstagramError?) { // Whatever you want to do ... // And don't forget to dismiss the 'InstagramLoginViewController' instagramLogin.dismiss(animated: true) } } ">
import InstagramLogin // <-- VERY IMPORTANT! ;)

class YourViewController: UIViewController {

    var instagramLogin: InstagramLoginViewController!

    // 1. Set your client info from Instagram's developer portal (https://www.instagram.com/developer/clients/manage)
    let clientId = ""
    let redirectUri = ""

    func loginWithInstagram() {

        // 2. Initialize your 'InstagramLoginViewController' and set your 'ViewController' to delegate it
        instagramLogin = InstagramLoginViewController(clientId: clientId, redirectUri: redirectUri)
        instagramLogin.delegate = self

        // 3. Customize it
        instagramLogin.scopes = [.basic, .publicContent] // [.basic] by default; [.all] to set all permissions
        instagramLogin.title = "Instagram" // If you don't specify it, the website title will be showed
        instagramLogin.progressViewTintColor = .blue // #E1306C by default

        // If you want a .stop (or other) UIBarButtonItem on the left of the view controller
        instagramLogin.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .stop, target: self, action: #selector(dismissLoginViewController))

        // You could also add a refresh UIBarButtonItem on the right
        instagramLogin.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .refresh, target: self, action: #selector(refreshPage))

        // 4. Present it inside a UINavigationController (for example)
        present(UINavigationController(rootViewController: instagramLogin), animated: true)
    }

    @objc func dismissLoginViewController() {
        instagramLogin.dismiss(animated: true)
    }

    @objc func refreshPage() {
        instagramLogin.reloadPage()
    }

    // ...
}

// MARK: - InstagramLoginViewControllerDelegate

extension YourViewController: InstagramLoginViewControllerDelegate {

    func instagramLoginDidFinish(accessToken: String?, error: InstagramError?) {

        // Whatever you want to do ...

        // And don't forget to dismiss the 'InstagramLoginViewController'
        instagramLogin.dismiss(animated: true)
    }
}

Contributing to this project

If you have feature requests or bug reports, feel free to help out by sending pull requests or by creating new issues. Please take a moment to review the guidelines written by Nicolas Gallagher:

License

InstagramLogin is available under the MIT license. See the LICENSE file for more info.

Credits

InstagramLogin is brought to you by Ander Goig and contributors to the project. If you're using InstagramLogin in your project, attribution would be very appreciated.

Author

Ander Goig, [email protected]

https://github.com/AnderGoig/InstagramLogin

You might also like...
FCLAuthSwift is a Swift library for the Flow Client Library (FCL) that enables Flow wallet authentication on iOS devices.
FCLAuthSwift is a Swift library for the Flow Client Library (FCL) that enables Flow wallet authentication on iOS devices.

FCLAuthSwift is a Swift library for the Flow Client Library (FCL) that enables Flow wallet authentication on iOS devices. Demo The demo a

A simple project for Face ID Authentication for iOS device using LocalAuthentication Framework

BiometricAuthentication This respository is a simple project for Face ID Authentication for iOS device using LocalAuthentication Framework and infoPli

Swift based OAuth library for iOS and macOS
Swift based OAuth library for iOS and macOS

OAuthSwift Swift based OAuth library for iOS and macOS. Support OAuth1.0, OAuth2.0 Twitter, Flickr, Github, Instagram, Foursquare, Fitbit, Withings, L

Krypton turns your iOS device into a WebAuthn/U2F Authenticator: strong, unphishable 2FA.

Krypton turns your iOS device into a WebAuthn/U2F Authenticator: strong, unphishable 2FA. Krypton implements the standardized FIDO Universal 2nd Facto

Allows users to pull in new song releases from their favorite artists and provides users with important metrics like their top tracks, top artists, and recently played tracks, queryable by time range.

Spotify Radar Spotify Radar is an iOS application that allows users to pull in new song releases from their favorite artists and provides users with i

Since Facebook introduced reactions in 2016, it became a standard in several applications as a way for users to interact with content. ReactionButton is a control that allows developers to add this functionality to their apps in an easy way. A quick and simple way to authenticate an Instagram user in your iPhone or iPad app.
A quick and simple way to authenticate an Instagram user in your iPhone or iPad app.

InstagramSimpleOAuth A quick and simple way to authenticate an Instagram user in your iPhone or iPad app. Adding InstagramSimpleOAuth to your project

CloudKit, Apple’s remote data storage service, provides a possibility to store app data using users’ iCloud accounts as a back-end storage service.
CloudKit, Apple’s remote data storage service, provides a possibility to store app data using users’ iCloud accounts as a back-end storage service.

CloudKit, Apple’s remote data storage service, provides a possibility to store app data using users’ iCloud accounts as a back-end storage service. He

An iOS application that uses Geo Locattion to allow students to authenticate their fingerprint in school grounds.
An iOS application that uses Geo Locattion to allow students to authenticate their fingerprint in school grounds.

WHUT-GeoLocation An iOS application that uses Geo Locattion to allow students to authenticate their fingerprint in school grounds. Has a form for cont

An iOS pre-permissions utility that lets developers ask users on their own dialog for calendar, contacts, location, photos, reminders, twitter, push notifications and more, before making the system-based permission request.

An iOS pre-permissions utility that lets developers ask users on their own dialog for calendar, contacts, location, photos, reminders, twitter, push notifications and more, before making the system-based permission request.

Cluster's reusable pre-permissions utility that lets developers ask the users on their own dialog for photos or contacts access, before making the system-based request.
Cluster's reusable pre-permissions utility that lets developers ask the users on their own dialog for photos or contacts access, before making the system-based request.

Cluster's reusable pre-permissions utility that lets developers ask the users on their own dialog for photos or contacts access, before making the system-based request. This is based on the Medium post by Cluster describing the different ways to ask for iOS permissions (https://medium.com/p/96fa4eb54f2c).

SharedImages Screen grabs Main Features Private & self-owned social media Users store their images in their own cloud storage (Dropbox or Google Drive

SharedImages Screen grabs Main Features Private & self-owned social media Users store their images in their own cloud storage (Dropbox or Google Drive

Push notifications allow developers to reach users, even when users aren't actively using an app!
Push notifications allow developers to reach users, even when users aren't actively using an app!

Push notifications allow developers to reach users, even when users aren't actively using an app! With the latest update of iOS Apple provide very useful extensions which are user-friendly. In this tutorial, I am going to share the configuration, set up of Notification with the media attachments like.

Virgil Core SDK allows developers to get up and running with Virgil Cards Service API quickly and add end-to-end security to their new or existing digital solutions to become HIPAA and GDPR compliant and more.
Virgil Core SDK allows developers to get up and running with Virgil Cards Service API quickly and add end-to-end security to their new or existing digital solutions to become HIPAA and GDPR compliant and more.

Virgil Core SDK Objective-C/Swift Introduction | SDK Features | Installation | Configure SDK | Usage Examples | Docs | Support Introduction Virgil Sec

 ReactionButton is a control that allows developers to add this functionality to their apps in an easy way.
ReactionButton is a control that allows developers to add this functionality to their apps in an easy way.

Since Facebook introduced reactions in 2016, it became a standard in several applications as a way for users to interact with content. ReactionButton is a control that allows developers to add this functionality to their apps in an easy way.

UI framework that allows developers to integrate an amazing selection interface into their applications

UI framework that allows developers to integrate an amazing selection interface into their applications! Each bubble has a set of parameters, which could be configured individually.

FlaneurImagePicker is an iOS image picker that allows users to pick images from different sources (ex: user's library, user's camera, Instagram...).                            It's highly customizable.
FlaneurImagePicker is an iOS image picker that allows users to pick images from different sources (ex: user's library, user's camera, Instagram...). It's highly customizable.

FlaneurImagePicker is a highly customizable iOS image picker that allows users to pick images from different sources (ex: device's library, device's c

Provenance is a native macOS application that interacts with the Up Banking Developer API to display information about your bank accounts, transactions, categories, tags and more.

Provenance Provenance is a native macOS application that interacts with the Up Banking Developer API to display information about your bank accounts,

A Simple iOS QR code scanner that allows users to enable their camera and local Photo Library accesses to scan the contents of the input QR codes.

iOS QR Code Scanner A Simple iOS QR code scanner using Swift UI. Jump to: ContentView.swift screenshot 1.1.5 NOTE: be aware of the new horizontal line

Comments
  • Can't install using Carthage

    Can't install using Carthage

    When trying to build your framework using Carthage, I get the following error:

    Dependency "InstagramLogin" has no shared framework schemes

    Full Terminal output:

    carthage update
    *** Fetching InstagramLogin *** Checking out InstagramLogin at "v1.2.0" *** xcodebuild output can be found in /var/folders/rx/jxm8sgs10tb0d3b3ndvpgygw0000gn/T/carthage-xcodebuild.cNZPbK.log *** Skipped building InstagramLogin due to the error: Dependency "InstagramLogin" has no shared framework schemes

    If you believe this to be an error, please file an issue with the maintainers at https://github.com/AnderGoig/InstagramLogin/issues/new

    My Cartfile only has this single line: github "AnderGoig/InstagramLogin"

    bug 
    opened by davidpasztor 1
  • Inconsistency Exception

    Inconsistency Exception

    I used it like the guide in the Readme file and this exception occured when I dismiss the view controller

    'NSInternalInconsistencyException', reason: 'Cannot modify constraints for UINavigationBar managed by a controller'
    

    Please note that I have a hidden navigation bar and i present the instagramLoginVC like this:

    present(UINavigationController(rootViewController: instagramLogin), animated: true)
    
    opened by minaMagedNaeem 1
  • Follow layout guides

    Follow layout guides

    That pull request fixes visual issues that may appear if presenting it from UITabBarController. Also it's more safe to use layout guides.

    Bug representation: screen shot 2018-04-03 at 18 17 52

    I haven't used newer safeArea guides, because WKWebView knows about it and uses it for content insets.

    Don't forget to add tag to 1.3.1 if pull request will be accepted.

    enhancement 
    opened by Sorix 0
Releases(v1.3.0)
  • v1.3.0(Dec 13, 2017)

    Added

    • New option to set all the scope permissions using: instagramLogin.scopes = [.all].
    • New method reloadPage() in case you want a button (on the UINavigationBar maybe) to refresh the WKWebView (see the Example project).

    Changed

    • The process of login has been redesigned, now it uses the delegate pattern instead of completion: method.
    • The Example project has been updated with those changes.
    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Nov 27, 2017)

  • v1.2.0(Nov 3, 2017)

    Added

    • Error handling for invalid requests.
    • Code is now simpler and more clean.

    Changed

    • Library renamed from IGAuth to InstagramLogin.

    Removed

    • 1Password library extension.
    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Sep 20, 2017)

    Added

    • Code is now simplier and more clean.

    Changed

    • Now you don't need your Client Secret to authenticate, so you don't have to store it into your client.
    • The Progress View now uses the new block-based KVO.

    Removed

    • On successful logins, the information about the authenticated user is not returned any more, just the access token.
    Source code(tar.gz)
    Source code(zip)
  • v1.0.3(Sep 13, 2017)

  • v1.0.2(Sep 9, 2017)

  • v1.0.1(Sep 9, 2017)

  • v1.0.0(Sep 9, 2017)

Owner
Ander Goig
👨🏻‍🎓Computer Science graduate 👨🏻‍💻 iOS Developer 🧡 Swift lover 🍎 Apple fanboy
Ander Goig
A quick and simple way to authenticate a Dropbox user in your iPhone or iPad app.

DropboxSimpleOAuth A quick and simple way to authenticate a Dropbox user in your iPhone or iPad app. Adding DropboxSimpleOAuth to your project CocoaPo

Ryan Baumbach 42 Dec 29, 2021
A quick and simple way to authenticate a Box user in your iPhone or iPad app.

BoxSimpleOAuth A quick and simple way to authenticate a Box user in your iPhone or iPad app. Adding BoxSimpleOAuth to your project CocoaPods CocoaPods

Ryan Baumbach 15 Mar 10, 2021
A UIViewController subclass for Instagram authentication.

InstagramAuthViewController A ViewController for Instagram authentication. A UIViewController subclass that handles showing the Instagram login page,

Isuru Nanayakkara 38 Jun 29, 2021
A simple library to make authenticating tvOS apps easy via their iOS counterparts.

Voucher The new Apple TV is amazing but the keyboard input leaves a lot to be desired. Instead of making your users type credentials into their TV, yo

Riz 516 Nov 24, 2022
Easy to use OAuth 2 library for iOS, written in Swift.

Heimdallr Heimdallr is an OAuth 2.0 client specifically designed for easy usage. It currently supports the resource owner password credentials grant f

trivago N.V. 628 Oct 17, 2022
OAuth2 framework for macOS and iOS, written in Swift.

OAuth2 OAuth2 frameworks for macOS, iOS and tvOS written in Swift 5.0. ⤵️ Installation ?? Usage ?? Sample macOS app (with data loader examples) ?? Tec

Pascal Pfiffner 1.1k Jan 2, 2023
Swift based OAuth library for iOS

OAuthSwift Swift based OAuth library for iOS and macOS. Support OAuth1.0, OAuth2.0 Twitter, Flickr, Github, Instagram, Foursquare, Fitbit, Withings, L

OAuthSwift 3.1k Jan 3, 2023
SimpleAuth is designed to do the hard work of social account login on iOS

SimpleAuth is designed to do the hard work of social account login on iOS. It has a small set of public APIs backed by a set of "providers"

Caleb Davenport 1.2k Nov 17, 2022
A simple OAuth library for iOS with a built-in set of providers

SwiftyOAuth is a small OAuth library with a built-in set of providers and a nice API to add your owns. let instagram: Provider = .instagram(clientID:

Damien 477 Oct 15, 2022
A simple way to implement Facebook and Google login in your iOS apps.

Simplicity Simplicity is a simple way to implement Facebook and Google login in your iOS apps. Simplicity can be easily extended to support other exte

Simplicity Mobile 681 Dec 18, 2022