Giter VIP home page Giter VIP logo

boxsimpleoauth's Introduction

BoxSimpleOAuth Build Status License Cocoapod Version Cocoapod Platform

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

iPhone5 Screenshot iPad Screenshot

Adding BoxSimpleOAuth to your project

Cocoapods

CocoaPods is the recommended way to add BoxSimpleOAuth to your project.

  1. Add BoxSimpleOAuth to your Podfile pod 'BoxSimpleOAuth'.
  2. Install the pod(s) by running pod install.
  3. Add BoxSimpleOAuth to your files with #import <BoxSimpleOAuth/BoxSimpleOAuth.h>.

Clone from Github

  1. Clone repository from github and copy files directly, or add it as a git submodule.
  2. Add all files from 'Source' directory to your project.

How To

  • Create an instance of BoxSimpleOAuthViewController and pass in an Box client ID, client secret, client callback URL and completion block to be executed with BoxLoginResponse and NSError arguments.
  • Once the instance of BoxSimpleOAuthViewController is presented (either as a modal or pushed on the navigation stack), it will allow the user to login. After the user logs in, the completion block given in the initialization of the view controller will be executed. The argument in the completion block, BoxLoginResponse, contains an accessToken and other login information for the authenticated user provided by Box API Response. If there is an issue attempting to authenticate, an error will be given instead.
  • By default, if there are issues with authentication, an UIAlertView will be given to the user. To disable this, and rely on the NSError directly, set the property shouldShowErrorAlert to NO.
  • A access_token can be refreshed using the underlying BoxAuthenticationManager.
  • Note: Even though an instance of the view controller itself can be initalized without client ID, client secret, client callback and completion block (to help with testing), this data must be set using the view controller's properties before it is presented to the user.

Example Usage

// Simplest Example:

BoxSimpleOAuthViewController
    *viewController = [[BoxSimpleOAuthViewController alloc] initWithClientID:@"panchos_client_id"
                                                                clientSecret:@"shhhhhh, I'm a secret"
                                                                 callbackURL:[NSURL URLWithString:@"http://chihuahuas.dog"]
                                                                  completion:^(BoxLoginResponse *response, NSError *error) {
                                                                      NSLog(@"My Access Token is: %@", response.accessToken);
                                                                  }];
[self.navigationController pushViewController:viewController
                                     animated:YES];

// Disable error UIAlertViews Example:

BoxSimpleOAuthViewController
    *viewController = [[BoxSimpleOAuthViewController alloc] initWithClientID:@"pancho_jrs_client_id"
                                                                clientSecret:@"shhhhhh, I'm a secret"
                                                                 callbackURL:[NSURL URLWithString:@"http://your.fancy.site"]
                                                                  completion:^(BoxLoginResponse *response, NSError *error) {
                                                                      NSLog(@"My OAuth Token is: %@", response.accessToken);
                                                                  }];
viewController.shouldShowErrorAlert = NO;

[self.navigationController pushViewController:viewController
                                     animated:YES];

Testing

To use the included Rakefile to run Specta tests, run the setup.sh script to bundle required gems and cocoapods:

$ ./setup.sh

Then run rake to run the tests on the command line:

$ bundle exec rake

Additional rake tasks can be seen using rake -T:

$ rake -T
rake build  # Build BoxSimpleOAuth
rake clean  # Clean
rake test   # Run Tests

Suggestions, requests, and feedback

Thanks for checking out BoxSimpleOAuth for your in-app Box authentication. Any feedback can be can be sent to: [email protected].

boxsimpleoauth's People

Contributors

rbaumbach avatar

Watchers

 avatar  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.