phantomappdevelopment / firebase-as3 Goto Github PK
View Code? Open in Web Editor NEWIntegrate Firebase Auth, Realtime Database and Storage in your Adobe AIR projects.
License: MIT License
Integrate Firebase Auth, Realtime Database and Storage in your Adobe AIR projects.
License: MIT License
First, I would like to thank you for setting up the documentation.
This may not be an issue, but there are something I am not sure about the URLStream for the Realtime Database.
Based on my testing in web using javascript, whenever there is a change in the database inside a node, it returns everything that the node contains, instead of 'only the changes'.
I would like to know, if URLStream is possible to kind of 'return everything contained by the node' in the ProgressEvent?
Do all of these methods work?
https://firebase.google.com/docs/database/rest/retrieve-data
I am trying to order my data alphabetically. After I turn my data into an Object I can't turn it into an array and sort it.
var sorted:Array = e.data //JSON.parse result
sorted.sortOn("1");
I saw that REST isn't able to keep list items at order either. I want to sort all the items I get from a JSON node alphanumerically.
HI,
The code works fine in the Air simulator, but don't work on device, I think is related to the URLStream.
I'm using myflashlabs anes for device, and your examples for debugging.
Thanks for the examples
~Sebas
I was researching about the issue of using the same email address for Facebook and Google login, it seems it doesn't work for security reasons.
You can see in this thread an explanation about it.
I will quote the relevant part for future readers:
To minimize the login UI clicks without compromising the account security, Firebase Authentication has a concept of 'trusted provider', where the identity provider is also the email service provider. For example, Google is the trusted provider for @gmail.com addresses, Yahoo is the trusted provider for @yahoo.com addresses, and Microsoft for @outlook.com addresses.
In the "One Account per Email address" mode, Firebase Authentication tries to link account based on email address. If a user logins from trusted provider, the user immediately signs into the account since we know the user owns the email address.
If there is an existing account with the same email address but created with non-trusted credentials (e.g. non-trusted provider or password), the previous credentials are removed for security reason. A phisher (who is not the email address owner) might create the initial account - removing the initial credential would prevent the phisher from accessing the account afterwards.
I will also update the examples later today to add a popup explaining the error.
Thanks you for your good job!
Do you know Firebase Phone Auth
if yes, Do you plan to add it?
snippet from: https://firebase.google.com/docs/auth/custom-email-handler
switch (mode) {
case 'resetPassword':
// Display reset password handler and UI.
handleResetPassword(auth, actionCode);
break;
case 'recoverEmail':
// Display email recovery handler and UI.
handleRecoverEmail(auth, actionCode);
break;
case 'verifyEmail':
// Display email verification handler and UI.
handleVerifyEmail(auth, actionCode);
break;
default:
// Error: invalid mode.
}
Can you authenticate google account? I had tried your samples, it was okay long time ago when you released first commit. But unfortunately right now I can't do that again. It seems google has new policy for web view. When I tried to authenticate my firebase using google got this message
403 Error
"This user-agent is not permitted to make OAuth authorisation request to Google as it is classified as an embedded user-agent (also known as a web-view). Per our policy, only browsers are permitted to make authorisation requests to Google. We offer several libraries and samples for native apps to perform authorisation request in browser."
I can not connect with facebook today.
Do you also have this problem?
thanks
I would like a progress bar for my uploader. I hear the only way to get progress events to fire is through file.upload. How would I do this?
So I followed your guide uploading images to storage and works perfectly. However, images uploaded to a folder (/images/) are not loaded in Image component in flex.
If the images is uploaded to root, works perfectly so my guess is that something is wrong with the %2F .
ex.
.appspot.com/leo.jpg <- this loads
.appspot.com/images%2Fleo.jpg <- this doesnt
Any ideas?
Thanks.
Hello!
Have you a AS3 plan for Cloud Firestore?
Thanks!
hello,
Thanks for your tutorial.Very usefull.
i can upload file (without progress event) but
i have a error ("bad request") when i want to upload file.with progress event.
Please where is my fault?
public static function uploadFileVideo(authToken:String,url,file:File):void
{ var header:URLRequestHeader = new URLRequestHeader("Authorization", "Bearer " + authToken);
var request:URLRequest = new URLRequest(Constants.FIREBASE_STORAGE_URL +url)
request.requestHeaders.push(header);
file.addEventListener(ProgressEvent.PROGRESS, progressHandler);
file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadCompleteDataHandler);
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.READ);
var bytes:ByteArray = new ByteArray();
fileStream.readBytes(bytes);
fileStream.close();
// var request:URLRequest = new URLRequest(url)
request.method = URLRequestMethod.POST;
request.data = bytes.toString();
request.contentType = "application/octet-stream";
file.uploadUnencoded(request);
}
I am trying to be able to login my users. I have saved my refresh token and use that in this function... but it wont work. What else do I need to login to firebase after a user closes and opens back up my application?
Here is my full login script. After it get's the refresh token it saves it to a file. Then when it needs to login again it pulls the refresh token out and sends it to handleRefreshToken
private function handleRefreshToken(refreshToken:String):void
{
var header:URLRequestHeader = new URLRequestHeader("Content-Type", "application/json");
var myObject:Object = new Object();
myObject.grant_type = "refresh_token";
myObject.refresh_token = refreshToken;
var request:URLRequest = new URLRequest("https://securetoken.googleapis.com/v1/token?key="+FIREBASE_API_KEY);
request.method = URLRequestMethod.POST;
request.data = JSON.stringify(myObject);
request.requestHeaders.push(header);
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, refreshTokenLoaded);
loader.addEventListener(IOErrorEvent.IO_ERROR, handleIOError);
loader.load(request);
}
private function refreshTokenLoaded(e:Event):void
{
e.target.removeEventListener(Event.COMPLETE, refreshTokenLoaded);
var rawData:Object = JSON.parse(e.currentTarget.data);
if (rawData.access_token == null)
{
toggleContent(0);
toggleIntro();
Dialog.service.toast("There was a problem logging you in. Please try again.");
FirebaseCrash.service.report(new Error("Login Error", 0));
}
else
{
authToken = rawData.access_token;
trace("REFRESH TOKEN LOADED.");
trace(e.target.data);
trace("Init tutorial");
if (signingIn)
{
toggleContent(CONTENT_FRAME);
toggleHomeScreen();
}
else
{
//Init bio fill//
toggleProfile(true);
}
}
Hi,
I am new to GitHub. So I don't think this should go here. But I found this works for uploading an image using flashplayer as opposed to AIR (i.e. no 'fileReference.uploadUnencoded()'). Useful if you are doing a web based app and don't wanna use java etc. Might wanna add this to the Upload example code section.
var appID:String = "YOUR-APP-ID";
public function uploadFile(): void {
var fileRef: FileReference = new FileReference();
var fileFilter: FileFilter = new FileFilter("Images", "*.jpg");
fileRef.addEventListener(Event.SELECT, fileSelected)
fileRef.browse([fileFilter]);
function fileSelected(event: Event): void {
fileRef.addEventListener(Event.COMPLETE, onFileLoaded);
fileRef.addEventListener(IOErrorEvent.IO_ERROR, ioError);
fileRef.addEventListener(ProgressEvent.PROGRESS, onProgress);
fileRef.load();
}
function onFileLoaded(event: Event): void {
var fr: FileReference = event.target as FileReference;
var data: ByteArray = fr["data"];
fileRef.removeEventListener(Event.COMPLETE, onFileLoaded);
fileRef.removeEventListener(IOErrorEvent.IO_ERROR, ioError);
fileRef.removeEventListener(ProgressEvent.PROGRESS, onProgress);
var request: URLRequest = new URLRequest("https://firebasestorage.googleapis.com/v0/b/"+appID+".appspot.com/o/ArtWorks%2F" + fr.name);
request.method = URLRequestMethod.POST;
request.data = data;
var loader: URLLoader = new URLLoader();
loader.addEventListener(flash.events.Event.COMPLETE, uploadComplete);
loader.addEventListener(flash.events.IOErrorEvent.IO_ERROR, ioError);
loader.load(request);
}
function uploadComplete(event:Event):void{
trace("upload complete")
}
function ioError(event: IOErrorEvent): void {
trace("ioError")
}
function onProgress(event: ProgressEvent): void {
trace(event.bytesLoaded + "/" + event.bytesTotal);
}
}
Can You help me? On OSX Mojave I can not login but on Hight Sierra evrything is working perfectly. I am developing an Air Desktop app.
Animate added to privacy enabled but on Mojave login always return 400 error code.
Is anyone else getting this issue on the FederatedExample.mxml example while implementing it on AIR on iOS?
Error #2044: Unhandled ErrorEvent:. text=The operation couldn’t be completed. (NSURLErrorDomain error -999.)
These are my AppTransportSecurity nodes in my iOS Info Additions in the app description xml file:
key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>firebaseio.com</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSIncludesSubdomains</key> <true/> <key>NSExceptionRequiresForwardSecrecy</key> <true/> </dict> <key>googleapis.com</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSIncludesSubdomains</key> <true/> <key>NSExceptionRequiresForwardSecrecy</key> <true/> </dict> <key>firebaseapp.com</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSIncludesSubdomains</key> <true/> <key>NSExceptionRequiresForwardSecrecy</key> <true/> </dict> <key>facebook.com</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSIncludesSubdomains</key> <true/> <key>NSExceptionRequiresForwardSecrecy</key> <true/> </dict> </dict> </dict>
If you are attempting to request a large portion of the database with a realtime connection, Firebase sends the results in parts. I made a makeshift script using your wiki that constantly tries to parse the json and only dispatches a complete event when it is successful. Though... is there a better way?
Normally works well, but sometimes the error appears Error #1132: Invalid JSON parse input
because it can be?
var rawData:Object = JSON.parse(message);
Let's say I have a large number of users or items I want to go over. I obviously don't want to download the entire list and parse it (I could but that's bad practice for large scale lists).
How would I do that? I'm trying to translate this to the best of my ability. https://firebase.google.com/docs/reference/rest/database/#section-query-parameters
My previous plan for messaging was to set up some sort of private node in the database and have both clients connect to it in real-time. Although, I'm noticing some truncated text at times...
So! Is cloud messaging possible? What's the difference? How does it work?
Hi,
It's been a while :)
Actually, I'm not sure if it's a typo, or if they've changed things over at Firebase. Anyway, the correct request type to verify an email address is "VERIFY_EMAIL" and not "EMAIL_VERIFY". The latter returns a status 400 error.
HTH. Cheers!
As I am basing everything off of your wiki tutorials, I am trying to delete a node.
https://github.com/sfxworks/FirebaseREST/blob/master/src/net/sfxworks/firebaseREST/Database.as
using the deleteNode method, I pass in my node URL (path/to/node) and it adds the .json and auth at the end of the URL. I get a null response yet the node is not deleted. What is happening?
@agentphantom I tried this example and I do get the refreshToken for signing in with Google but not for Facebook
This is sort of related. I am trying to get google and facebook auth tokens to use so I can pass to a java firebase ane. I have been trying to pass the auth-tokens I get from signing in but they aren't working. Is this because I'm getting firebase's auth tokens and not the providers? If so..can you explain to me how I can get these?
Hello!
How to delete à folder (and sublime folders)?
Thanks.
In Javascript, it is possible to pre-define the function/codes to be executed on the server side through the onDisconnect event. (such as remove its content)
Is it possible to do so in AS3?
Thanks in advance.
Great work on this 👍
Although it's for AS3, you were right when you said that it's easy to adapt to other languages :)
I was wondering if you could provide the processes to sign a user out of firebase, and link accounts as described on this article?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.