GithubHelp home page GithubHelp logo

neuralnoise / firebase-simple-login-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from googlearchive/firebase-simple-login-java

0.0 2.0 0.0 104 KB

Firebase Simple Login - Java / Android Client

License: MIT License

Shell 4.31% Java 95.69%

firebase-simple-login-java's Introduction

Firebase Simple Login - Android Client

Firebase Simple Login is a simple, easy-to-use authentication service built on top of Firebase Custom Login, allowing you to authenticate users without any server code.

Enable authentication via a number of third-party providers, anonymous login, or email / password authentication without having to manually store authentication credentials or run a server.

Deprecation Warning!

Firebase Simple Login for Android is now a part of the core Firebase Android library. As a result, this standalone Simple Login client is being deprecated. We encourage everyone to upgrade to the latest version of the Firebase Android Client to get the latest and greatest features. If you are still using this deprecated Simple Login client, you can find documentation for it here.

You can read more about this change on our blog and see the updated login documentation on our website. The updated documentation includes migration plans, but if you have any other questions, please reach out to us.

Installation

To install in your application, download from the Firebase CDN, or install as a Maven dependency:

<dependency>
  <groupId>com.firebase</groupId>
  <artifactId>firebase-simple-login</artifactId>
  <version>[1.4.0,)</version>
</dependency>

See https://www.firebase.com/docs/security/simple-login-java-overview.html for complete documentation and API reference.

Configuration

The Firebase Simple Login Java Client supports email & password, Facebook, Google, Twitter, and anonymous authentication methods. Before adding to your application, you'll need to first enable these auth. providers in your app.

To get started, visit the Simple Login tab in Firebase Forge, at https://<YOUR-FIREBASE>.firebaseio.com. There you may enable / disable auth. providers, setup OAuth credentials, and configure valid OAuth request origins.

Usage

Start monitoring user authentication state in your application by instantiating the Firebase Simple Login client with a Firebase reference, and callback.

Firebase ref = new Firebase("https://SampleChat.firebaseIO.com");
SimpleLogin authClient = new SimpleLogin(ref, getApplicationContext());

Note that instantiating the Simple Login constructor with a valid Android context is required in order for the client to seamlessly persist and load sessions across application restarts.

Once you have instantiated the client library, check the user's authentication status:

authClient.checkAuthStatus(new SimpleLoginAuthenticatedHandler() {
  public void authenticated(FirebaseSimpleLoginError error, FirebaseSimpleLoginUser user) {
    if (error != null) {
      // Oh no! There was an error performing the check
    } else if (user == null) {
      // No user is logged in
    } else {
      // There is a logged in user
    }
  }
});

In addition, you can monitor the user's authentication state with respect to your Firebase by observing events at a special location: .info/authenticated

Firebase authRef = ref.getRoot().child(".info/authenticated");
authRef.addValueEventListener(new ValueEventListener() {
  public void onDataChange(DataSnapshot snap) {
    boolean isAuthenticated = snap.getValue(Boolean.class);
  }
  public void onCancelled() {}
});

If the user is logged out, try authenticating using the provider of your choice:

authClient.loginWithEmail("[email protected]", "very secret", new SimpleLoginAuthenticatedHandler() {
  public void authenticated(FirebaseSimpleLoginError error, FirebaseSimpleLoginUser user) {
    if(error != null) {
      // There was an error logging into this account
    }
    else {
      // We are now logged in!
    }
  }
});

Testing / Compiling From Source

Interested in manually debugging from source, or submitting a pull request? Don't forget to read the Contribution Guidelines.

License

The MIT License

Copyright © 2014 Firebase [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

firebase-simple-login-java's People

Contributors

robertdimarco avatar firebase-ops avatar vikrum avatar aleksandarilic avatar

Watchers

James Cloos avatar Starbuck 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.