Giter Site home page Giter Site logo

phonegapi's Introduction

Helper routines for using phonegap / cordova with Google's gapi.

gapi is a set of API's that google provides for accessing their services. If you are using phonegap or cordova, gapi.auth.signIn and gapi.auth.authorize will not work because the oauth redirect can only go to a file: URI, which is not supported by gapi. Provide alternate API's for managing authorization/authentication. You can authenticate with phonegapi and then use the other gapi API's that require authentication.

Calling the API's

Add the following script tags to your index.html. phonegapi requires jquery and the google client.js file

<script type="text/javascript" src="jquery-1.11.1.js"></script>
<script src="https://apis.google.com/js/client.js"></script>
<script src="phonegapi.js"></script>

The code uses the cordova inappbrowser plugin. If you are using cordova CLI, do:

cordova plugin add org.apache.cordova.inappbrowser

See test.js for examples on how to sign in, persist the tokens in local storage, refresh tokens if they expire,...

Creating credentials

When creating credentials in google developer console. Selected 'Installed App' and then then 'other'. You will need the client id and client secret to call signIn and refreshSignIn.

API synopsis

phonegapi.signIn: Use login screen to obtain the access tokens for google authenticated APIs phonegapi.signOut: Disable the access tokens so google API's will fail phonegapi.refreshSignIn: Refresh the tokens obtained earlier to get access without going through a login screen

phonegapi's People

Contributors

kaushik947 avatar rscohn2 avatar

Watchers

 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.