2016-06-16 10 views
0

Firebaseでかなり奇妙な問題が発生しました。私は、GoogleService-Info.plistなどを含むcocoaPodsを介してfirebaseをインストールしましたが、Firebaseから値を読み取ろうとすると、エラー:私は1時間から除いて、新しいプロジェクトを開始しようとしているこの一つ一つの時間を頂いているSwift/Firebaseデータベース無効なトークンエラー

2016-06-16 12:10:04.598 MP[78421:13128189] [FirebaseDatabase] Authentication failed: invalid_token (Invalid claim 'aud' in auth token.)

- しかし、私は新しいものを始めていて、私は、今、そのプロジェクトを放棄しました。簡単なコードは次のとおりです。

import UIKit 
import Firebase 
import FirebaseDatabase 
class ViewController: UIViewController { 
    var ref:FIRDatabaseReference! 
    override func viewDidLoad() { 
     super.viewDidLoad() 
     ref = FIRDatabase.database().reference() 
     ref.observeSingleEventOfType(.Value) { (snapshot:FIRDataSnapshot) in 
      var val = snapshot.value! as? String 
      print(val) 
     } 
    } 
} 

どうすればこの問題を解決できますか?

答えて

6

このエラーメッセージは、トークン内のプロジェクトが、アプリケーションが接続しているプロジェクトと一致しないことを示しています。からpost on the firebase-talk group

There are a couple ways you may hit this:

  1. You've changed your GoogleService-Info.plist to point at a different project, but your app still has a cached token from a previous run.

  2. I believe the iOS Simulator shares the keychain between apps, so if you have multiple apps using Firebase, one app might be picking up the token cached by another app. This only happens in the simulator and we're working on changing the Firebase SDK to avoid this.

In either case, you can probably resolve the issue by doing an explicit signOut() call before initializing Firebase Database.

+1

私はFIRAuth.auth()?signoutを実行しました。ありがとう! – askaale

+0

よろしくお願いします。私たちはこの振る舞いの改善に取り組んでいます。私の答えが役に立つなら、その左側のupvoteボタンをクリックしてください。あなたの質問に答えた場合は、チェックマークをクリックしてそれを受け入れます。そうすれば、他の人はあなたが(十分に)助けられたことを知ることができます。 –

+2

これは私には役に立たなかった。デバイスでも起こります。シムをクリアして、アプリの両方のバージョンでサインアウトしました。それでもトークンについて不平を言う。どのようにそれを修正するか分かりません。 –

関連する問題