Not all API commands I have implemented and tested, if you have problems, then ask in the comments or in a new thread.
With this class you can register and log in your users via email and password. And a lot more...
Setup:
Author: Alexander Stolte
Version: 1.1
You can get the map keys in the code or on the online documentation from Firebase
Changelog
With this class you can register and log in your users via email and password. And a lot more...
Setup:
- put your API Key in the Class_Globals
Private const API_KEY As String = "AIzaSyDPXXXXXX"
Author: Alexander Stolte
Version: 1.1
- FirebaseAuthREST
- Functions:
- changeEmail (idToken As String, email As String, returnSecureToken As Boolean) As ResumableSub
Change email
Firebase Auth REST API
firebase.google.com
email - The user's new email.
returnSecureToken - Whether or not to return an ID and refresh token. - changePassword (idToken As String, password As String, returnSecureToken As Boolean) As ResumableSub
Change password
Firebase Auth REST API
firebase.google.com
password - User's new password.
returnSecureToken - Whether or not to return an ID and refresh token. - Class_Globals As String
- confirmEmailVerification (oobCode As String) As ResumableSub
Confirm email verification
Firebase Auth REST API
firebase.google.com - confirmPasswordReset (oobCode As String, newPassword As String) As ResumableSub
Confirm password reset
Firebase Auth REST API
firebase.google.com
newPassword - The user's new password. - createAuthUri (identifier As String, continueUri As String) As ResumableSub
Fetch providers for email
Firebase Auth REST API
firebase.google.com
continueUri - The URI to which the IDP redirects the user back. For this use case, this is just the current URL. - deleteAccount (idToken As String) As ResumableSub
Delete account
Firebase Auth REST API
firebase.google.com - getErrorCode (root As Map) As Int
code: 400 - getErrorMap (root As Map) As Map
reason: invalid
domain: global
message: EMAIL_NOT_FOUND - getErrorMessage (root As Map) As String
message: EMAIL_NOT_FOUND - Initialize As String
Initializes the object. You can add parameters to this method if needed. - IsInitialized As Boolean
Tests whether the object has been initialized. - sendEmailVerification (requestType As String, idToken As String) As ResumableSub
Send email verification
Firebase Auth REST API
firebase.google.com
idToken - The Firebase ID token of the user to verify. - sendPasswordResetEmail (requestType As String, email As String) As ResumableSub
Send password reset email
Firebase Auth REST API
firebase.google.com
email - User's email address. - signInAnonymously (returnSecureToken As Boolean) As ResumableSub
Sign in anonymously
Firebase Auth REST API
firebase.google.com - signInEmailPW (email As String, password As String, returnSecureToken As Boolean) As ResumableSub
Sign in with email / password
Firebase Auth REST API
firebase.google.com
password - The password for the account.
returnSecureToken - Whether or not to return an ID and refresh token. Should always be true. - signUpEmailPW (email As String, password As String, returnSecureToken As Boolean) As ResumableSub
Sign up with email / password
Firebase Auth REST API
firebase.google.com
password - The password for the user to create.
returnSecureToken - Whether or not to return an ID and refresh token. Should always be true. - verifyPasswordResetCode (oobCode As String) As ResumableSub
Verify password reset code
Firebase Auth REST API
firebase.google.com
- changeEmail (idToken As String, email As String, returnSecureToken As Boolean) As ResumableSub
- Functions:
You can get the map keys in the code or on the online documentation from Firebase
Firebase Auth REST API
firebase.google.com
Usage Example:
Wait For (fa_rest.signInEmailPW("[email protected]","MySecurePassword123!",True)) complete (root As Map)
If root.Get("success") = True Then
For Each k As String In root.Keys
Log("Key: " & k & CRLF & "Value: " & root.Get(k))
Next
Else
Log("ErrorCode: " & fa_rest.getErrorCode(root))
Log("ErrorMessage: " & fa_rest.getErrorMessage(root))
Log("Reason: " & fa_rest.getErrorMap(root).Get("reason"))
Log("Domain: " & fa_rest.getErrorMap(root).Get("domain"))
Log("Message: " & fa_rest.getErrorMap(root).Get("message"))
End If
Success Result:
Key: expiresIn
Value: 3600
Key: kind
Value: identitytoolkit#VerifyPasswordResponse
Key: displayName
Value:
Key: idToken
Value: eyJhbGciOiJSUzI1NiIsImtpZCI6Ijc2MjNlMTBhMDQ1MTQwZjFjZmQ0YmUwNDY2Y2Y4MDM1MmI1OWY4MWUiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL3NlY3VyZXRva2VuLmdvb2dsZS5jb20vZmlyLWF1dGhyZXN0IiwiYXVkIjoiZmlyLWF1dGhyZXN0IiwiYXV0aF90aW1lIjoxNTk0MjAxMzMxLCJ1c2VyX2lkIjoiSU90TjVqVmN1YWhjQWt2S0ExZWM0eDdPU0hHMiIsInN1YiI6IklPdE41alZjdWFoY0FrdktBMWVjNHg3T1NIRzIiLCJpYXQiOjE1OTQyMDEzMzEsImV4cCI6MTU5NDIwNDkzMSwiZW1haWwiOiJhbGV4Ljk4LnN0b2x0ZUBnbXguZGUiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiZmlyZWJhc2UiOnsiaWRlbnRpdGllcyI6eyJlbWFpbCI6WyJhbGV4Ljk4LnN0b2x0ZUBnbXguZGUiXX0sInNpZ25faW5fcHJvdmlkZXIiOiJwYXNzd29yZCJ9fQ.PkoZaKyMxbz7U6s2fW2DQisGTgs5rbPJiqcJbVipopda1vi25iYGOyq0jDhaHdTFX4If_umKEsiRzWpncafKs7Kev1_aqDV-XAAHbEoO_zOyomsopRYIjzzL2NoUuSN-667ArzJURgA0VjB0s8GYN0hDeWqbISvq3Kgdu3569MQHDLd01BcFKc2-9Tv6ZoFGqsWTRWyZZmtu7PDga97vmsiQ01eiogmXY7giGbAMs4q9XdcP3vAzlYi8H5Tr61ywsKFhoPhhk6w4dH1o_RrErS5WiPKl-325QA-qZ99VBfMdgLoIyfCj898UbXP7cpq2E0vJrqMmdaALJsWfNhFzDg
Key: registered
Value: true
Key: localId
Value: IOtN5jVcuahcAkvKA1ec4x7OSHG2
Key: email
Value: [email protected]
Key: refreshToken
Value: AE0u-NcTYspSYujdVRs5Bx3eXMoVDeDRUNX3NGUd9xWfq-ty8r7NDeDvEhX14GGWeoXdWpzwT2oTkBGU5QCNdqhcipb_wCbDgIXX9IZ6lyatl_tCEfhupu5zYD3hnYDVetT2diHrxUZfwqUR-ZJBHUlDtA_3VkAAXNUdXhychL2pY7BELgawWOkrwDJbndMrdfGuyMDYDJ1mHTmUDLabouTDykvtmVo7rg
Key: success
Value: true
Error Result:
ErrorCode: 400
ErrorMessage: EMAIL_NOT_FOUND
Reason: invalid
Domain: global
Message: EMAIL_NOT_FOUND
- 1.00
- Release
- 1.01
- get Errors check if item in map exists
- Add refreshToken - Exchange a refresh token for an ID token
- 1.02
- Add getUserData - Thanks to @Blueforcer
Attachments
Last edited: