From 4cf0bba6abaa541e85d57cbcc5ab04c6ceb1c40d Mon Sep 17 00:00:00 2001 From: Nicolas Garnier Date: Wed, 6 Apr 2016 16:36:56 +0200 Subject: [PATCH] Switched to version eap.3 of Firebase JS. Some additional polish. Change-Id: I7c07263ce0675b8cc6d9e9e84639ec263e8cc2bf --- auth/README.md | 31 ++++++------------- auth/{quickstart => }/anon.html | 17 +++++----- auth/{quickstart => }/customauth.html | 17 +++++----- auth/{quickstart => }/email.html | 26 ++++++++-------- .../exampletokengenerator/auth.html | 4 +-- auth/{quickstart => }/facebook.html | 24 ++++++-------- auth/firebase.json | 15 ++++----- auth/{quickstart => }/google.html | 29 +++++++++-------- auth/{quickstart => }/index.html | 8 ++--- database/README.md | 24 +++----------- database/firebase.json | 15 ++++----- database/{quickstart => }/index.html | 12 ++++--- functions/README.md | 4 +-- functions/index.html | 8 ++--- functions/scripts/main.js | 4 +-- storage/README.md | 19 ++---------- storage/firebase.json | 15 ++++----- storage/{quickstart => }/index.html | 13 +++----- 18 files changed, 117 insertions(+), 168 deletions(-) rename auth/{quickstart => }/anon.html (91%) rename auth/{quickstart => }/customauth.html (91%) rename auth/{quickstart => }/email.html (88%) rename auth/{quickstart => }/exampletokengenerator/auth.html (97%) rename auth/{quickstart => }/facebook.html (88%) rename auth/{quickstart => }/google.html (88%) rename auth/{quickstart => }/index.html (85%) rename database/{quickstart => }/index.html (89%) rename storage/{quickstart => }/index.html (91%) diff --git a/auth/README.md b/auth/README.md index 18dd50990..8f26c060b 100644 --- a/auth/README.md +++ b/auth/README.md @@ -1,16 +1,17 @@ Firebase Auth Quickstart ============================= -The Firbase auth quickstart demonstrate several methods for signing in. +The Firebase auth quickstart demonstrates several methods for signing in. The Firebase email/password quickstart demonstrates using a Firebase stored email & password - you can both create and sign in a user. -The Firebase Google Sign in quickstart demonstrates using a Google account to authenticate to Firebase. +The Firebase Google Sign in quickstart demonstrates using a Google account to authenticate to Firebase. The Firebase Facebook Login quickstart demonstrates using a Facebook account to authenticate to Firebase. -The Firebase custom auth web quickstart demonstrates how to authenticate with the Firebase user management -system with a user who has been authenticated from your own pre-existing authentication system.This is done by generating a token in a specific format, which is signed using the private key from a service account downloaded from the Google Developer Console. This token can then be passed to your client application which uses it to authenticate to Firebase. +The Firebase Anonymous auth quickstart demonstrates authenticate to Firebase anonymously. + +The Firebase custom auth web quickstart demonstrates how to authenticate to Firebase with a user who has been authenticated from your own pre-existing authentication system. This is done by generating a token in a specific format, which is signed using the private key from a service account downloaded from the Google Developer Console. This token can then be passed to your client application which uses it to authenticate to Firebase. Introduction ------------ @@ -21,35 +22,21 @@ Getting Started --------------- - Set up your project on the [Firebase Console](http://g.co/firebase). -- Enable the authentication method you want to use in the User Management tab - you don't need to enable custom auth. +- Enable the authentication method you want to use in the Auth tab - you don't need to enable custom auth. - In the [Google Developer Console](https://console.developers.google.com), access the project you created in the Firebase Console. - In the search box search for an select "Credentials" and create a Browser API key restricted to the domain you are using. - For Custom Auth, also create a new Service Account, and download the JSON representation. - For Google Sign In you will need to create a client ID with a Javascript Origin field set to your domain. - Edit the .html for the authentication method you want to try and fill in the API key and Database URL values in index.html. You can see the database URL from the Database section on the Firebase Console. -- Open the sample .html in a web browser. Note that for Google Sign In you must use a webserver of some kind, file:// hosted pages wont work. +- Open the sample `.html` in a web browser. Note that for Google Sign In you must use a webserver of some kind, file:// hosted pages wont work. Support ------- https://developers.google.com/firebase/support/ + License ------- -Copyright 2016 Google, Inc. - -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE file distributed with this work for -additional information regarding copyright ownership. The ASF licenses this -file to you under the Apache License, Version 2.0 (the "License"); you may not -use this file except in compliance with the License. You may obtain a copy of -the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations under -the License. +© Google, 2016. Licensed under an [Apache-2](../LICENSE) license. \ No newline at end of file diff --git a/auth/quickstart/anon.html b/auth/anon.html similarity index 91% rename from auth/quickstart/anon.html rename to auth/anon.html index 13e01455d..f6b007ae9 100644 --- a/auth/quickstart/anon.html +++ b/auth/anon.html @@ -21,9 +21,9 @@ Anonymous Authentication Example - + - + - + + - + + - + + + - + + @@ -55,26 +55,29 @@ var databaseUrl = 'YOUR_DATABASE_URL_HERE'; // Also remember to change the Google Client ID above! - + +
@@ -34,7 +34,7 @@

Firebase Authentication

-

There are multiple different methods available for authentication with Firebase. Ensure that +

There are multiple methods available for authentication with Firebase. Ensure that you have added configuration to each file, and that the appropriate method has been enabled in the Firebase Console authentication panel. Note: custom auth does not require enabling.

@@ -48,8 +48,6 @@

Firebase Authentication

  • Email/Password
  • Google Sign In
  • Facebook Login
  • -
  • Twitter Login
  • -
  • Github Login
  • Custom Authentication
  • diff --git a/database/README.md b/database/README.md index cf110de18..36db2a997 100644 --- a/database/README.md +++ b/database/README.md @@ -14,9 +14,10 @@ Getting Started --------------- - Set up your project on the [Firebase Console](http://g.co/firebase). -- Copy the Database URL from the Database section of the console. -- In the [Google Developer Console](https://console.developers.google.com), access the project you created in the Firebase Console. In the search box search for an select "Credentials" and create a Browser API Key restricted to the origin of your web server. -- Edit quickstart/index.html and fill in the API key and Database URL values in index.html. +- Copy the **Database URL** from the Database section of the console. +- In the [Google Developer Console](https://console.developers.google.com), access the project you created in the Firebase Console. In the + search box search for an select "Credentials" and create a Browser API Key restricted to the origin of your web server. +- Edit quickstart/index.html and fill in the **API key** and **Database URL** values in `index.html`. - Run `firebase serve` using the Firebase CLI tool to launch a local server. - Alternative, open the sample index.html in a web browser. @@ -28,19 +29,4 @@ https://developers.google.com/firebase/support/ License ------- -Copyright 2016 Google, Inc. - -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE file distributed with this work for -additional information regarding copyright ownership. The ASF licenses this -file to you under the Apache License, Version 2.0 (the "License"); you may not -use this file except in compliance with the License. You may obtain a copy of -the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations under -the License. +© Google, 2016. Licensed under an [Apache-2](../LICENSE) license. diff --git a/database/firebase.json b/database/firebase.json index 9245ba9e4..a63e4a3f7 100644 --- a/database/firebase.json +++ b/database/firebase.json @@ -1,9 +1,10 @@ { - "firebase": "YOUR_PROJECT_ID_HERE", - "public": "quickstart", - "ignore": [ - "firebase.json", - "**/.*", - "**/node_modules/**" - ] + "hosting": { + "public": "./", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ] + } } diff --git a/database/quickstart/index.html b/database/index.html similarity index 89% rename from database/quickstart/index.html rename to database/index.html index b51757034..b9ea7b303 100644 --- a/database/quickstart/index.html +++ b/database/index.html @@ -4,12 +4,14 @@ - + - + - + + + @@ -39,9 +41,9 @@

    Realtime Database Example

    // Configure the Firebase SDK. var config = { apiKey: apiKey, - databaseUrl: databaseUrl + databaseURL: databaseUrl }; - var app = firebase.App.initialize(config); + var app = firebase.initializeApp(config); var database = app.database(); var myDataRef = database.ref().child('messages'); // [END configure] diff --git a/functions/README.md b/functions/README.md index 8493e0216..4a3fabcb6 100644 --- a/functions/README.md +++ b/functions/README.md @@ -122,7 +122,7 @@ In this sample we use the following data model: ``` - `\functions-quickstart-12345\messages` is a list of Objects. New messages get pushed in this list. - - A message is an Object with one attribute: `text`. We chose this instead of a simple String for consistency with the other Firebase samples and codelabs so that you can easilly combbine them. + - A message is an Object with one attribute: `text`. We chose this instead of a simple String for consistency with the other Firebase samples and codelabs so that you can easily combine them. ## See the results @@ -179,4 +179,4 @@ We'd love that you contribute to the project. Before doing so please read our [C ## License -© Google, 2015. Licensed under an [Apache-2](../LICENSE) license. +© Google, 2016. Licensed under an [Apache-2](../LICENSE) license. diff --git a/functions/index.html b/functions/index.html index 91c364f7c..15e8f8247 100644 --- a/functions/index.html +++ b/functions/index.html @@ -41,8 +41,8 @@ - - + + @@ -93,9 +93,9 @@

    Last Messages

    - + - + diff --git a/functions/scripts/main.js b/functions/scripts/main.js index c9800dd81..50df059ce 100644 --- a/functions/scripts/main.js +++ b/functions/scripts/main.js @@ -25,9 +25,9 @@ var databaseUrl = ''; // Initialize Firebase Database. var config = { apiKey: apiKey, - databaseUrl: databaseUrl + databaseURL: databaseUrl }; -var app = firebase.App.initialize(config); +var app = firebase.initializeApp(config); var database = app.database(); var messagesRef = database.ref().child('messages'); diff --git a/storage/README.md b/storage/README.md index 49b1db530..edcb41045 100644 --- a/storage/README.md +++ b/storage/README.md @@ -13,7 +13,7 @@ Getting Started - Set up your project on the [Firebase Console](http://g.co/firebase). - Manually enable a Firebase Storage bucket. -- Edit index.html and fill in the API key and project ID (e.g. foobar-f3dc) values. +- Edit index.html and fill in the API key and project ID (e.g. `foobar-f3dc`) values. - Open the sample index.html in a web browser or run `firebase serve` Support @@ -24,19 +24,4 @@ https://developers.google.com/firebase/support/ License ------- -Copyright 2016 Google, Inc. - -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE file distributed with this work for -additional information regarding copyright ownership. The ASF licenses this -file to you under the Apache License, Version 2.0 (the "License"); you may not -use this file except in compliance with the License. You may obtain a copy of -the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations under -the License. +© Google, 2016. Licensed under an [Apache-2](../LICENSE) license. diff --git a/storage/firebase.json b/storage/firebase.json index 9245ba9e4..a63e4a3f7 100644 --- a/storage/firebase.json +++ b/storage/firebase.json @@ -1,9 +1,10 @@ { - "firebase": "YOUR_PROJECT_ID_HERE", - "public": "quickstart", - "ignore": [ - "firebase.json", - "**/.*", - "**/node_modules/**" - ] + "hosting": { + "public": "./", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ] + } } diff --git a/storage/quickstart/index.html b/storage/index.html similarity index 91% rename from storage/quickstart/index.html rename to storage/index.html index 65bc3630b..b7fcfcf47 100644 --- a/storage/quickstart/index.html +++ b/storage/index.html @@ -21,12 +21,12 @@ Firebase Storage Example - + - + - +
    @@ -67,7 +67,7 @@

    File URL:

    apiKey: apiKey, projectId: projectId }; - var app = firebase.App.initialize(config); + var app = firebase.initializeApp(config); var auth = app.auth(); var storageRef = app.storage().ref(); @@ -111,12 +111,9 @@

    File URL:

    document.getElementById('file').disabled = true; app.addAuthStateListener(function(event) { - var user = event.user; + var user = event.currentUser; console.log('User Object:', user); document.getElementById('file').disabled = false; - - }, function(error) { - console.error('Auth Listener Error', error); }); auth.signInAnonymously().then(function(user) {