GithubHelp home page GithubHelp logo

andergoig / instagramlogin Goto Github PK

View Code? Open in Web Editor NEW
71.0 7.0 19.0 32.99 MB

Simple way to authenticate Instagram accounts on iOS.

License: MIT License

Swift 91.07% Ruby 8.93%
ios swift authentication social-login instagram instagram-api xcode cocoapods carthage instagram-authentication

instagramlogin's Introduction

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 clientId = "<YOUR CLIENT ID GOES HERE>"
static let redirectUri = "<YOUR REDIRECT URI GOES HERE>"

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.

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 = "<YOUR CLIENT ID GOES HERE>"
    let redirectUri = "<YOUR REDIRECT URI GOES HERE>"

    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

instagramlogin's People

Contributors

andergoig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

instagramlogin's Issues

get data from installed the app

If the device has installed the instagram app then is it possible to get login data from instagram app. just like facebook

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)

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"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.