Skip to content

Commit

Permalink
Minor fix for Authentication examples to work correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Jan 26, 2021
1 parent 47d2036 commit 8e1bdfb
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Firebase Arduino Client Library for ESP8266 and ESP32


Google's Firebase Arduino ClientLibrary for ESP8266 and ESP32 v 1.0.2
Google's Firebase Arduino ClientLibrary for ESP8266 and ESP32 v 1.0.3


This library supports ESP8266 and ESP32 MCU from Espressif. The following are platforms in which libraries are also available.
Expand Down
5 changes: 3 additions & 2 deletions examples/Authentications/Custom_Token/Custom_Token.ino
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ void prepareDatabaseRules(const char *path, const char *var, const char *readVal
//We will sign in using legacy token (database secret) for full RTDB access
config.signer.tokens.legacy_token = FIREBASE_AUTH;
Firebase.begin(&config, &auth);
//Set to empty string to sign in with other tokens
config.signer.tokens.legacy_token = "";

Serial.println("------------------------------------");
Serial.println("Read database ruless...");
Expand Down Expand Up @@ -343,6 +341,9 @@ void prepareDatabaseRules(const char *path, const char *var, const char *readVal
{
Serial.println("Failed to read the database rules, " + fbdo.errorReason());
}

//Set to empty string to sign in with other tokens
config.signer.tokens.legacy_token = "";
}

void printResult(FirebaseData &data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,6 @@ void prepareDatabaseRules(const char *path, const char *var, const char *readVal
//We will sign in using legacy token (database secret) for full RTDB access
config.signer.tokens.legacy_token = FIREBASE_AUTH;
Firebase.begin(&config, &auth);
//Set to empty string to sign in with other tokens
config.signer.tokens.legacy_token = "";

Serial.println("------------------------------------");
Serial.println("Read database ruless...");
Expand Down Expand Up @@ -307,6 +305,9 @@ void prepareDatabaseRules(const char *path, const char *var, const char *readVal
{
Serial.println("Failed to read the database rules, " + fbdo.errorReason());
}

//Set to empty string to sign in with other tokens
config.signer.tokens.legacy_token = "";
}

void printResult(FirebaseData &data)
Expand Down
5 changes: 3 additions & 2 deletions examples/Authentications/Email_Password/Email_Password.ino
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ void prepareDatabaseRules(const char *path, const char *var, const char *readVal
//We will sign in using legacy token (database secret) for full RTDB access
config.signer.tokens.legacy_token = FIREBASE_AUTH;
Firebase.begin(&config, &auth);
//Set to empty string to sign in with other tokens
config.signer.tokens.legacy_token = "";

Serial.println("------------------------------------");
Serial.println("Read database ruless...");
Expand Down Expand Up @@ -264,6 +262,9 @@ void prepareDatabaseRules(const char *path, const char *var, const char *readVal
{
Serial.println("Failed to read the database rules, " + fbdo.errorReason());
}

//Set to empty string to sign in with other tokens
config.signer.tokens.legacy_token = "";
}

void printResult(FirebaseData &data)
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=Firebase Arduino Client Library for ESP8266 and ESP32

version=1.0.2
version=1.0.3

author=Mobizt

Expand Down
8 changes: 4 additions & 4 deletions src/Firebase_ESP_Client.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Google's Firebase ESP Client Main class, Firebase_ESP_Client.cpp version 1.0.2
* Google's Firebase ESP Client Main class, Firebase_ESP_Client.cpp version 1.0.3
*
* This library supports Espressif ESP8266 and ESP32
*
Expand Down Expand Up @@ -75,7 +75,9 @@ void Firebase_ESP_Client::begin(FirebaseConfig *config, FirebaseAuth *auth)
_cfg->signer.tokens.status = token_status_uninitialized;
}

if (Signer.tokenSigninDataReady())
if (_cfg->signer.tokens.legacy_token.length() > 0)
Signer.setTokenType(token_type_legacy_token);
else if (Signer.tokenSigninDataReady())
{
if (_auth->token.uid.length() == 0)
Signer.setTokenType(token_type_oauth2_access_token);
Expand All @@ -84,8 +86,6 @@ void Firebase_ESP_Client::begin(FirebaseConfig *config, FirebaseAuth *auth)
}
else if (Signer.userSigninDataReady())
Signer.setTokenType(token_type_id_token);
else if (_cfg->signer.tokens.legacy_token.length() > 0)
Signer.setTokenType(token_type_legacy_token);

struct fb_esp_url_info_t uinfo;
_cfg->_int.fb_auth_uri = _cfg->signer.tokens.token_type == token_type_legacy_token || _cfg->signer.tokens.token_type == token_type_id_token;
Expand Down
2 changes: 1 addition & 1 deletion src/Firebase_ESP_Client.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Google's Firebase ESP Client Main class, Firebase_ESP_Client.h version 1.0.2
* Google's Firebase ESP Client Main class, Firebase_ESP_Client.h version 1.0.3
*
* This library supports Espressif ESP8266 and ESP32
*
Expand Down
2 changes: 1 addition & 1 deletion src/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Firebase Arduino Client Library for ESP8266 and ESP32


Google's Firebase Arduino Client Library for ESP8266 and ESP32 v 1.0.2
Google's Firebase Arduino Client Library for ESP8266 and ESP32 v 1.0.3


## Global functions
Expand Down
3 changes: 2 additions & 1 deletion src/database/FB_RTDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

FB_RTDB::FB_RTDB()
{

}

FB_RTDB::~FB_RTDB()
Expand Down Expand Up @@ -3801,7 +3802,7 @@ bool FB_RTDB::handleResponse(FirebaseData *fbdo)
}

dataTime = millis();

if (chunkBufSize > 1)
{
while (chunkBufSize > 0)
Expand Down

0 comments on commit 8e1bdfb

Please sign in to comment.