saif
saif

Reputation: 93

How to get idToken ( Auth key) for firebase with ESP8266 using AT commands

I was trying to connect to firebase using AT commands on ESP8266 (ESP01). Without authenticated rules I'm able to write to a node.

But with authenticated rules, I'm having a trouble getting Auth Key. With curl it is working fine but AT commands returns error.

These are the curl commands which works to get Auth key using web API key.

curl -X POST -d "Content-length:63" "https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=<API_KEY>&email=<email>&password=<password>&returnSecureToken=true"

which works fine and returns idToken that can be used as <Auth_key> for posting to firebase node like below.

curl -X PUT https://myproject-default-rtdb.asia-southeast1.firebasedatabase.app/UsersData/mynode.json?auth=<idToken>  -d "{\"Test\":\"data\"}"

But when I try using the same using AT commands with ESP8266 (ESP01) it does not works.

To get token key I tried to connect to server using below command,

AT+CIPSTART="SSL","https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=<API_KEY>",443

but it return error.

I tried also

1) AT+CIPSTART="SSL","https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword",443

2) AT+CIPSTART="SSL","https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=<API_KEY>&email=<email>&password=<password>&returnSecureToken=true",443

All returns error. How do I get token id from google API using AT command?

Below connection is successful, but I need to authenticate using token key.

AT+CIPSTART="SSL","myproject-default-rtdb.asia-southeast1.firebasedatabase.app",443

Upvotes: 0

Views: 48

Answers (0)

Related Questions