9#include <firebase/app.h>
10#include <firebase/auth.h>
12#include "firebase/app.h"
13#include "firebase/auth.h"
43 static void onTokenRefreshResult(
const firebase::Future<std::string>& completed_future,
void* ref_data) {
44 const MessageManagerLock lock(Thread::getCurrentThread());
45 if (!lock.lockWasGained())
48 if (completed_future.status() != firebase::kFutureStatusComplete) {
53 if (completed_future.error()) {
54 std::string error =
"Firebase getting token error: error code ";
60 reference->setToken(*completed_future.result());
70 if (firebase::App::GetInstance() !=
nullptr)
73 firebase::AppOptions auth_app_options = firebase::AppOptions();
74 auth_app_options.set_app_id(
"");
75 auth_app_options.set_api_key(
"");
76 auth_app_options.set_project_id(
"");
78 firebase::App::Create(auth_app_options);
97 auth_ = firebase::auth::Auth::GetAuth(firebase::App::GetInstance());
104 bool hasAuth()
const {
return auth_ !=
nullptr; }
110 firebase::auth::Auth* auth()
const {
return auth_; }
120 void setToken(
const std::string&
token) { token_ =
token; }
126 std::string
token()
const {
return token_; }
132 bool loggedIn() {
return auth_ && auth_->current_user() !=
nullptr; }
142 if (auth_ ==
nullptr || auth_->current_user() ==
nullptr)
145 firebase::Future<std::string> future = auth_->current_user()->GetToken(
false);
146 future.OnCompletion(onTokenRefreshResult,
this);
150 firebase::auth::Auth* auth_;
A no-op stub implementation used when authentication is disabled.
Definition authentication.h:163
static void create()
No-op create method.
Definition authentication.h:168
bool loggedIn()
Always returns false, indicating no user is logged in.
Definition authentication.h:180
void refreshToken()
No-op token refresh method.
Definition authentication.h:185
std::string token()
Returns an empty token string.
Definition authentication.h:174
static void writeErrorLog(String error_log)
Appends an error message to an error log file.
Definition load_save.cpp:1140