GithubHelp home page GithubHelp logo

rinov / gappauth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elsesiy/gappauth

0.0 2.0 0.0 21 KB

Convenient Wrapper for AppAuth with Google Services written in Swift 4.

License: BSD 2-Clause "Simplified" License

Ruby 6.18% Swift 93.82%

gappauth's Introduction

GAppAuth

pod License Twitter

This is a drop-in class to handle AppAuth with Google Services (currently supporting only iOS).

Installation via cocoapods

Just add this dependency to your Podfile:

pod GAppAuth

The transitive dependency to GTMAppAuth is added automatically.

Manually

Add GTMAppAuth dependency to your Podfile (Cocoapods) or copy the files manually to your project directory. Add GAppAuth.swift to your project and set-up you project as follows to use AppAuth with Google Services.

  1. Setup your project (iOS) at https://console.developers.google.com to retrieve ClientID and iOS scheme URL.
  2. Enable Google APIs as desired.
  3. Add ClientId and RedirectUri to your Info.plist:
  <key>GAppAuth</key>
  <dict>
    <key>RedirectUri</key>
    <string>com.googleusercontent.apps.YOUR-CLIENT-ID:/oauthredirect</string>
    <key>ClientId</key>
    <string>YOUR-CLIENT-ID.apps.googleusercontent.com</string>
  </dict>
  1. Add Custom URL-Scheme to your project:
  <key>CFBundleURLTypes</key>
  <array>
    <dict>
      <key>CFBundleURLSchemes</key>
        <array>
          <string>com.googleusercontent.apps.YOUR-CLIENT-ID</string>
        </array>
    </dict>
  </array>
  1. In order to authorize for any Google Service, you'd need to append the respective scope to the authorization request via: GAppAuth.shared.appendAuthorizationRealm (i.e. kGTLRAuthScopeDrive for Google Drive access).
  2. From any UIViewController start the authorization workflow by calling GAppAuth.shared.authorize.
  3. You might want to retrieve any existing authorization upon start of the app which can be done via GAppAuth.shared.retrieveExistingAuthorizationState.
  4. There are two closures you can monitor in order to be notified about any changes stateChangeCallback or errors errorCallback. Note: In case of a revoked access by the user, both callbacks will be called.
A good spot for 5. and 7. is the AppDelegate's didFinishLaunchingWithOptions.

Feel free to add any remarks or open up a PR.

gappauth's People

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.