質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

Google Cloud Platform

Google Cloud Platformは、Google社がクラウド上で提供しているサービス郡の総称です。エンドユーザー向けサービスと同様のインフラストラクチャーで運営されており、Webサイト開発から複雑なアプリ開発まで対応可能です。

Google App Engine

Google App Engineは、Googleの管理するデータセンター上でウェブアプリケーションの開発が可能なクラウドコンピュータ技術です。Java、Python、Go用にSDKが用意されています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Google

Googleは、アメリカ合衆国に位置する、インターネット関連のサービスや製品を提供している企業です。検索エンジンからアプリケーションの提供まで、多岐にわたるサービスを提供しています。

Q&A

解決済

1回答

347閲覧

Firebaseのgoogleサインインが使えない

退会済みユーザー

退会済みユーザー

総合スコア0

Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

Google Cloud Platform

Google Cloud Platformは、Google社がクラウド上で提供しているサービス郡の総称です。エンドユーザー向けサービスと同様のインフラストラクチャーで運営されており、Webサイト開発から複雑なアプリ開発まで対応可能です。

Google App Engine

Google App Engineは、Googleの管理するデータセンター上でウェブアプリケーションの開発が可能なクラウドコンピュータ技術です。Java、Python、Go用にSDKが用意されています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Google

Googleは、アメリカ合衆国に位置する、インターネット関連のサービスや製品を提供している企業です。検索エンジンからアプリケーションの提供まで、多岐にわたるサービスを提供しています。

0グッド

0クリップ

投稿2018/01/01 11:47

編集2018/01/01 11:53

Firebaseのサンプル「FriendlyChat」を、
GoogleAppEngine上で実行しようとしています。

Googleアカウントでログイン後にチャットの投稿が出来るようになるものなのですが、
SignInボタンを押下してもログイン出来ません。
Firebaseのサーバにデプロイすると、ログイン・チャットの投稿が出来ます。
GoogleAppEngineの場合、何か特殊な処理が必要でしょうか?

index.html

<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> (省略) <link href="http://vjs.zencdn.net/5.11.6/video-js.css" rel="stylesheet"> </head> <body> <div class="demo-layout mdl-layout mdl-js-layout mdl-layout--fixed-header"> <header class="mdl-layout__header mdl-color-text--white mdl-color--light-blue-700"> <div class="mdl-cell mdl-cell--12-col mdl-cell--12-col-tablet mdl-grid"> <div class="mdl-layout__header-row mdl-cell mdl-cell--12-col mdl-cell--12-col-tablet mdl-cell--12-col-desktop"> </div> <div id="user-container"> <div hidden id="user-pic"></div> <div hidden id="user-name"></div> <button hidden id="sign-out" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-color-text--white"> Sign-out </button> <button hidden id="sign-in" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-color-text--white"> <i class="material-icons">account_circle</i>Sign-in with Google </button> </div> </div> </header> <main class="mdl-layout__content mdl-color--grey-100"> <div id="messages-card-container" class="mdl-cell mdl-cell--12-col mdl-grid"> <!-- Messages container --> <div id="messages-card" class="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--12-col mdl-cell--6-col-tablet mdl-cell--6-col-desktop"> <div class="mdl-card__supporting-text mdl-color-text--grey-600"> <div id="messages"> <span id="message-filler"></span> </div> <form id="message-form" action="#"> <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> <input class="mdl-textfield__input" type="text" id="message"> <label class="mdl-textfield__label" for="message">Message...</label> </div> <button id="submit" disabled type="submit" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"> Send </button> </form> <form id="image-form" action="#"> <button id="submitImage" title="Add an image" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-color--amber-400 mdl-color-text--white"> <i class="material-icons">image</i> </button> </form> </div> </div> <div id="must-signin-snackbar" class="mdl-js-snackbar mdl-snackbar"> <div class="mdl-snackbar__text"></div> <button class="mdl-snackbar__action" type="button"></button> </div> </div> </main> </div> <script src="https://www.gstatic.com/firebasejs/4.8.0/firebase.js"></script> <script> var config = { apiKey: "XX", authDomain: "XX.com", databaseURL: "https://XXX.firebaseio.com", projectId: "XYZ", storageBucket: "XXYY.appspot.com", messagingSenderId: "1234" }; firebase.initializeApp(config); </script> <script src="scripts/main.js"></script> <script src="http://vjs.zencdn.net/5.11.6/video.js"></script> </body> </html>

main.js

'use strict'; function FriendlyChat() { this.checkSetup(); this.messageList = document.getElementById('messages'); this.messageForm = document.getElementById('message-form'); this.messageInput = document.getElementById('message'); this.submitButton = document.getElementById('submit'); this.submitImageButton = document.getElementById('submitImage'); this.imageForm = document.getElementById('image-form'); this.userPic = document.getElementById('user-pic'); this.userName = document.getElementById('user-name'); this.signInButton = document.getElementById('sign-in'); this.signOutButton = document.getElementById('sign-out'); this.signInSnackbar = document.getElementById('must-signin-snackbar'); this.messageForm.addEventListener('submit', this.saveMessage.bind(this)); this.signOutButton.addEventListener('click', this.signOut.bind(this)); this.signInButton.addEventListener('click', this.signIn.bind(this)); var buttonTogglingHandler = this.toggleButton.bind(this); this.messageInput.addEventListener('keyup', buttonTogglingHandler); this.messageInput.addEventListener('change', buttonTogglingHandler); this.submitImageButton.addEventListener('click', function(e) { e.preventDefault(); }.bind(this)); this.initFirebase(); } FriendlyChat.prototype.initFirebase = function() { this.auth = firebase.auth(); this.database = firebase.database(); this.store = firebase.storage(); this.auth.onAuthStateChanged(this.onAuthStateChanged.bind(this)); }; FriendlyChat.prototype.loadMessages = function() { this.messagesRef = this.database.ref('messages'); this.messagesRef.off(); var setMessage = function(data) { var val = data.val(); this.displayMessage(data.key, val.name, val.text, val.photoUrl, val.imageUrl); }.bind(this); this.messagesRef.limitToLast(12).on('child_added', setMessage); this.messagesRef.limitToLast(12).on('child_changed', setMessage); }; FriendlyChat.prototype.saveMessage = function(e) { e.preventDefault(); if (this.messageInput.value && this.checkSignedInWithMessage()) { var currentUser = this.auth.currentUser; this.messagesRef.push({ name: currentUser.displayName, text: this.messageInput.value, photoUrl: currentUser.photoURL || '/images/profile_placeholder.png' }).then(function() { FriendlyChat.resetMaterialTextfield(this.messageInput); this.toggleButton(); }.bind(this)).catch(function(error) { console.error('Error writing new message to Firebase Database', error); }); } }; FriendlyChat.prototype.setImageUrl = function(imageUri, imgElement) { imgElement.src = imageUri; }; FriendlyChat.prototype.signIn = function() { var provider = new firebase.auth.GoogleAuthProvider(); firebase.auth().signInWithPopup(provider).then(function(result) { var token = result.credential.accessToken; var user = result.user; }).catch(function(error) { }); }; FriendlyChat.prototype.signOut = function() { this.auth.signOut(); }; FriendlyChat.prototype.onAuthStateChanged = function(user) { if (user) { // User is signed in! var profilePicUrl = user.photoURL; var userName = user.displayName; this.userPic.style.backgroundImage = 'url(' + profilePicUrl + ')'; this.userName.textContent = userName; this.userName.removeAttribute('hidden'); this.userPic.removeAttribute('hidden'); this.signOutButton.removeAttribute('hidden'); this.signInButton.setAttribute('hidden', 'true'); this.loadMessages(); this.saveMessagingDeviceToken(); } else { this.userName.setAttribute('hidden', 'true'); this.userPic.setAttribute('hidden', 'true'); this.signOutButton.setAttribute('hidden', 'true'); this.signInButton.removeAttribute('hidden'); } }; FriendlyChat.prototype.checkSignedInWithMessage = function() { if (this.auth.currentUser) { return true; } var data = { message: 'You must sign-in first', timeout: 2000 }; this.signInSnackbar.MaterialSnackbar.showSnackbar(data); return false; }; FriendlyChat.resetMaterialTextfield = function(element) { element.value = ''; element.parentNode.MaterialTextfield.boundUpdateClassesHandler(); }; FriendlyChat.MESSAGE_TEMPLATE = '<div class="message-container">' + (省略) '</div>'; FriendlyChat.prototype.displayMessage = function(key, name, text, picUrl, imageUri) { var div = document.getElementById(key); if (!div) { var container = document.createElement('div'); container.innerHTML = FriendlyChat.MESSAGE_TEMPLATE; div = container.firstChild; div.setAttribute('id', key); this.messageList.appendChild(div); } if (picUrl) { div.querySelector('.pic').style.backgroundImage = 'url(' + picUrl + ')'; } div.querySelector('.name').textContent = name; var messageElement = div.querySelector('.message'); if (text) { messageElement.textContent = text; messageElement.innerHTML = messageElement.innerHTML.replace(/\n/g, '<br>'); } else if (imageUri) { var image = document.createElement('img'); image.addEventListener('load', function() { this.messageList.scrollTop = this.messageList.scrollHeight; }.bind(this)); this.setImageUrl(imageUri, image); messageElement.innerHTML = ''; messageElement.appendChild(image); } setTimeout(function() {div.classList.add('visible')}, 1); this.messageList.scrollTop = this.messageList.scrollHeight; this.messageInput.focus(); }; FriendlyChat.prototype.toggleButton = function() { if (this.messageInput.value) { this.submitButton.removeAttribute('disabled'); } else { this.submitButton.setAttribute('disabled', 'true'); } }; FriendlyChat.prototype.checkSetup = function() { if (!window.firebase || !(firebase.app instanceof Function) || !firebase.app().options) { window.alert('You have not configured and imported the Firebase SDK.'); } }; window.onload = function() { window.friendlyChat = new FriendlyChat(); };

足りない情報等ありましたら、ご指摘お願いします。


気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

お使いのGoogleAppEngineのURLを設定に追加してください.
ウェブコンソール画面で,Authentication > ログイン方法 > 承認済みドメイン です.

投稿2018/01/01 16:11

Yatima

総合スコア1159

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2018/01/01 20:50

おお、まさにそこでございました!ありがとうございます!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問