Firebase Authentication in Unity with Google with Loopback IP method (REST API) [UPDATE]

  Рет қаралды 5,911

uNicoDev

uNicoDev

Күн бұрын

Пікірлер: 50
@infinitenight7246
@infinitenight7246 2 жыл бұрын
Video was super super helpful. Very underrated. Thank you so much for this. This is applicable to more than just games too! Awesome content! Keep it up 😀
@akosdanielbollok
@akosdanielbollok 2 ай бұрын
Hey, awesome video! A few questions. How would you implement so the user's session would last, also use the authenticated user data anywhere in the game?
@kovekove3278
@kovekove3278 7 ай бұрын
I tried the both methods but while playing in editor and pressing the sing in with google button it redirect me to browser and asking which id to sign in also on selecting one successfully signing in but if i go back to the editor it prints this exception plz help me buddy Proyecto26.RequestException: HTTP/1.1 400 Bad Request
@VigneshGajendran-cg7pl
@VigneshGajendran-cg7pl 7 ай бұрын
@unicodev We have faced the same issues as the above, we have downloaded the code from your Git Hub and changed all the things per your video instructions but got the error. Can you please help me?
@dewakeadilan
@dewakeadilan 3 ай бұрын
is it possible to do this with unity authentication token instead of firebase's?
@irafaisal8019
@irafaisal8019 8 ай бұрын
How can we get the client secret for android in google api ? When I create credential for android I can't find any option for client secret key
@user-js7ud9du2y
@user-js7ud9du2y 2 жыл бұрын
i hope this approach never gets deprecated i hate using random plugins
@JJDSG
@JJDSG 2 жыл бұрын
Thanks 👍
@Schaken-Mods
@Schaken-Mods 2 жыл бұрын
I started a new project for this, downloaded the Rest Client for unity from the asset store, and then installed this. I get 2 compiling errors. Script updater for Library\Bee\artifacts\1900b0aE.dag\Unity.Timeline.Editor.dll failed to produce updates.txt file Library\PackageCache\com.unity.timeline@1.2.2\Editor\Utilities\BreadcrumbDrawer.cs(217,49): error CS0234: The type or namespace name 'PrefabStageUtility' does not exist in the namespace
@studiomalaka
@studiomalaka 2 жыл бұрын
Hi uNicoDev, thanks for the great tutorial! Would it be possible to show also how to use the standard Firebase email/password authentication? I wonder if it's still possible...
@StvNewsKaipamangalam
@StvNewsKaipamangalam 2 жыл бұрын
​ @uNicoDev Can you explain how to upload and download files from firebase storage using rest API in unity
@PatrickCreations
@PatrickCreations Жыл бұрын
Si sentiva dalla pronuncia che sei italiano 😂 comunque grazie del tutorial, sono alle prime armi con firebase e mi ha salvato!
@ergare17
@ergare17 Жыл бұрын
Thanks for all the guidance Nico! Do you know how to get the user profile information about Gmail when the user is logged in? The json response doesn't show things like the username for example
@joaomarianodasilva2630
@joaomarianodasilva2630 2 жыл бұрын
Olá amigo estou tentado fazer uma integração da unity com firebase para controlar um relé com o esp8266 mas não estou conseguindo fazer a alteração da string, se você puder mim ajudar ficarei muito agradecido. Seria mais ou menos assim: chave: led valor: "0" assim: led: "0" e quando eu clicasse novamente no botão mudaria de estado para led: "1"
@neerajchauhan3262
@neerajchauhan3262 2 жыл бұрын
can you please make the video of sign in with apple , facebook with firebase for unity WebGL . please....
@bhanuprakash2447
@bhanuprakash2447 2 жыл бұрын
Hey Nico, Will this work for unity WebGL? I have Created OAuth client Id as web application.
@aboodriazy3387
@aboodriazy3387 Жыл бұрын
were you able to do it? and i am trying same thing
@abdulmaliqjinad1244
@abdulmaliqjinad1244 2 жыл бұрын
Hello Nico, how to you change the response to a successful web page that has been hosted online. I tried replacing the success sign in string to the web page link in the responseHtml but that didn't work rather it printed the link as a text for me.
@uNicoDev
@uNicoDev 2 жыл бұрын
In the HttpCodeListener class, on line 57 I am setting the context.Response to the responseHtml. Instead of doing that, you can do context.Response.Redirect("URL"). Docs: docs.microsoft.com/en-us/dotnet/api/system.net.httplistenerresponse.redirect?view=net-6.0
@aquadury7354
@aquadury7354 2 жыл бұрын
Hey, Nico! Thanks for the great guide, but your flow has a serious flaw: you are using the Authorisation Code flow and storing ClientSecret directly in your code. Anyone can disassemble and use it. Do you have any ideas of correcting the flow? Thanks in advance and warm regards!
@uNicoDev
@uNicoDev 2 жыл бұрын
Hey thanks for watching! Unfortunately the client secret has to be stored on the client in order for the set up to work (because it's a client secret xd). Of course, using Firebase mobile SDK's makes the secret hidden under a bunch of obfuscation but it is still there! So I don't think the flow can be corrected but you could make the secret harder to find by obfuscating the application and using IL2CPP when building. In the company I work for we own this obfuscator which is pretty good IMO: assetstore.unity.com/packages/tools/utilities/obfuscator-48919 but there are probably cheaper solutions out there that do the job. Finally, you should consider restricting the things you can do with the client secret on the google cloud console, so even in the unfortunate case it is stolen, users can just sign up and sign in, they don't gain any additional functionality that your app doesn't already offer them
@aquadury7354
@aquadury7354 2 жыл бұрын
​@@uNicoDev Hey, mate! Thanks for the comment and sorry for the late answer. I have made some research and found a solution to a problem. 1) Even if you can try to protect your code and variables on the client, it's still insecure and can be catched at the moment of sending the request to google from clients device. 2) Guidelines for the access code flow (which we are using) explicitly say that client secret should be stored apart from the client. 3) So I made an ASP NET Web API (or any other type of web server) which holds a client secret and created an endpoint which accepts Access Code, exchanges it for google token and then returns it in responsel. (public async Task PostGoogleAccesCode(string AccessCode)) 4) That's it! We are using access code flow and safe! P.S. I'm not familiar with FireBase cloud functions, but I believe it's a perfect option for implementing a safe flow without creating your own backend.
@aboodriazy3387
@aboodriazy3387 Жыл бұрын
I tried in WEBGL only working in editor not working when i build and run.. any help please
@uNicoDev
@uNicoDev Жыл бұрын
Hey, could you elaborate on what is going wrong? Every now and then Unity updates the default player html page and breaks stuff so you might have to rename the unityInstance so that my javascript code can see it... I tried to document this in the README.md of the Github project code
@aboodriazy3387
@aboodriazy3387 Жыл бұрын
​@@uNicoDev it goes to the link where i select the account to login after i select the account then it comes on browser, Site cant be reach! what exactlty i have to do to fix it?
@uNicoDev
@uNicoDev Жыл бұрын
​@@aboodriazy3387 What method are you using from the ones showed in the video? Because I don't think the loopback ip address will work on WebGL, but invoking a cloud function could still do the trick! Also there might be a simpler hacky solution in WebGL, where you can redirect the browser to the web app itself, but with the token as a query parameter, and then have Unity read it like this: answers.unity.com/questions/1285359/how-to-read-url-parameters-from-unity-webgl-build.html
@aboodriazy3387
@aboodriazy3387 Жыл бұрын
@@uNicoDev ah I actually trying loop back method
@aboodriazy3387
@aboodriazy3387 Жыл бұрын
@@uNicoDev first I am trying to redirect to web app as you mention with token as query parameter if it did not work I will go for other way thanks for the reply
@aboodriazy3387
@aboodriazy3387 2 жыл бұрын
the loop back method will work on Iphone?
@uNicoDev
@uNicoDev 2 жыл бұрын
I think you are better off using the firebase SDK of unity for mobile devices so it handles signing in internally and you don't have to do anything
@abdulmaliqjinad1244
@abdulmaliqjinad1244 2 жыл бұрын
Hey Nico, thank you for this, by the way how do we implement for sign out
@uNicoDev
@uNicoDev 2 жыл бұрын
The thing that actually keeps the user authenticated when you are using rest apis is just the refresh token (which you can use to generate Id tokens to authenticate). So to sign out, simply discard that refresh token string
@abdulmaliqjinad1244
@abdulmaliqjinad1244 2 жыл бұрын
@@uNicoDev if we are to use this method for facebook sign in, what are the things we are going to be changing?
@uNicoDev
@uNicoDev 2 жыл бұрын
It should be similar, just in application openurl you have to use the Facebook APIs instead of Google... Tho I haven't looked into them much, you prob need to do a Facebook developer account and find their docs
@marioshadjiaros2856
@marioshadjiaros2856 2 жыл бұрын
Can you share the cloud functions method please?
@uNicoDev
@uNicoDev 2 жыл бұрын
The code for all the methods is available on Github (the link is in the description). The link for the cloud function method branch is this one: github.com/rotolonico/Firebase-Auth-with-Google-REST-API/tree/cloud-function-setup
@uNicoDev
@uNicoDev 2 жыл бұрын
The actual backend cloud functions are in Firebase/functions/index.js
@Sepci0
@Sepci0 Жыл бұрын
Around 5:30 You want to create a secret, and put it in the code. Well, then if you ship tour game, someone can extract this code and use it, so it's not that "secret"
@ahmadkhairihafizkhairulhis2009
@ahmadkhairihafizkhairulhis2009 2 жыл бұрын
hey nico how about making a video for firebase mobile login for unity
@uNicoDev
@uNicoDev 2 жыл бұрын
I can look into it, the Firebase SDK surely makes stuff much easier for Unity mobile so that's why I tend to focus more on the REST APIs side of things
@IloBizon1
@IloBizon1 2 жыл бұрын
Hi guy. Nice video.Can you do video about uploading pictures in your firebase chat. It is very important
@Anonym-mw5lz
@Anonym-mw5lz 2 жыл бұрын
Hi, if I use the URI "localhost:5000" and click on the "Login with Google" button the window to select my google account pops up, but as soon as I choose one the next window opens with the following message "Bad Request (Invalid host)". The URI on this page has all parameters (code, scope, etc...). I use the loopback IP method.
@Anonym-mw5lz
@Anonym-mw5lz 2 жыл бұрын
Does anyone have a similar problem?
@uNicoDev
@uNicoDev 2 жыл бұрын
Sorry for the late response... I didn't encounter this. You already tried just putting localhost:5000 (without http)? Also maybe see if the port is already preoccupied with something else or your firewall is blocking the listener. Additionally you could step with a debugger as soon as you open the listener on localhost and actually see if you get the callback when you go to the URL
@gwynbleidd777
@gwynbleidd777 2 жыл бұрын
I'm having this issue as well. it works on desktop, but it doesn't on android.
@Anonym-mw5lz
@Anonym-mw5lz 2 жыл бұрын
@@uNicoDev I tried everything you mentioned but it somehow won't work...
@logicosetest1936
@logicosetest1936 2 жыл бұрын
the loopback method will work on android device in android project?
@uNicoDev
@uNicoDev 2 жыл бұрын
It should but i haven't tested it. Tho for Android i encourage you to use the unity firebase SDK that handles the authentication on its own
@sekiro3139
@sekiro3139 2 жыл бұрын
@@uNicoDev Hey, Can I use unity firebase SDK for Authentication in IOS devices?
@uNicoDev
@uNicoDev 2 жыл бұрын
@@sekiro3139 Yeah you can authenticate with apple id with Firebase: firebase.google.com/docs/auth/ios/apple
Adding Firebase SDK In Unity WebGL builds!
25:21
uNicoDev
Рет қаралды 21 М.
Smart Sigma Kid #funny #sigma
00:14
CRAZY GREAPA
Рет қаралды 6 МЛН
Зу-зу Күлпаш 2. Интернет мошенник
40:13
ASTANATV Movie
Рет қаралды 625 М.
She's very CREATIVE💡💦 #camping #survival #bushcraft #outdoors #lifehack
00:26
MP3 CDs: a hybrid "format" that never existed, yet was surprisingly common
34:18
Technology Connections
Рет қаралды 102 М.
Adding Firestore to your Unity game - Firecasts
16:06
Firebase
Рет қаралды 14 М.
Unity Async Await - Make Your Game Run Smoother!
13:17
Sunny Valley Studio
Рет қаралды 39 М.
Sending Web Requests in Unity - UnityWebRequest
4:12
Tarodev
Рет қаралды 22 М.
How to set up Firebase Authentication in Unity (REST API)
43:59
Firebase Authentication in unity with Google Provider
12:25
Fusion Prix
Рет қаралды 22 М.