GithubHelp home page GithubHelp logo

ruslan14 / instagramauthviewcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from isuru-nanayakkara/instagramauthviewcontroller

0.0 0.0 0.0 18 KB

A UIViewController subclass for Instagram authentication.

License: MIT License

Swift 100.00%

instagramauthviewcontroller's Introduction

InstagramAuthViewController

A ViewController for Instagram authentication.

A UIViewController subclass that handles showing the Instagram login page, the authentication dance and finally returning the access token that can be used to communicate with the Instagram API afterwards.

Inspired by Instagram-Auth-iOS. Used PhotoBrowser as a stepping stone. I rewrote the login part in Swift, replced third-party library code with built-in Cocoa Touch frameworks and made it reusable.

Requirements

  • iOS 8.0+
  • Xcode 7.3<

Installation

Manually

  1. Download or clone the repo.
  2. Open the source folder.
  3. Add InstagramAuthViewController.swift to your project.
  4. Profit(?)!

Usage example

  • Go to Instagram's developer portal and register your application.
  • Take note of the client ID, client secret and redirect URI values.
let clientId = "<YOUR CLIENT ID>"
let clientSecret = "<YOUR CLIENT SECRET>"
let redirectUri = "<YOUR REDIRECT URI>"

Storyboards

  • Simply add the InstagramAuthViewController as the UIViewController's class in the Identity inspector.

let instagramAuthViewController = segue.destinationViewController as! InstagramAuthViewController
instagramAuthViewController.delegate = self
instagramAuthViewController.clientId = clientId
instagramAuthViewController.clientSecret = clientSecret
instagramAuthViewController.redirectUri = redirectUri

Programmatically

  • Initialize an instance of InstagramAuthViewController and present it like a normal ViewController.
let instagramAuthViewController = InstagramAuthViewController(clientId: clientId, clientSecret: clientSecret, redirectUri: redirectUri)
instagramAuthViewController.delegate = self
presentViewController(instagramAuthViewController, animated: true, completion: nil)
  • Either way, don't forget to implement the InstagramAuthDelegate.
func instagramAuthControllerDidFinish(accessToken: String?, error: NSError?) {
    if let error = error {
        print("Error logging in to Instagram: \(error.localizedDescription)")
    } else {
        print("Access token: \(accessToken!)")
    }
}

Contribute & Bug Fixes

I would love for you to contribute to InstagramAuthViewController, check the LICENSE file for more info. Pull requests, bug fixes, improvements welcome.

Meta

Isuru Nanayakkara โ€“ @IJNanayakkara โ€“ [email protected]

Distributed under the MIT license. See LICENSE for more information.

https://github.com/Isuru-Nanayakkara

instagramauthviewcontroller's People

Contributors

isuru-nanayakkara avatar

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.