Actually it can be any but if you have it to be your backend it would be tricky to handle. So when Google responds with successful authorisation it sends us back a redirect response(HTTP redirect response). This redirect response will contain the redirect url(what we have given in the cloud console along with some query parameters such as the token). Now when the browser reads this redirect response it's gonna load that into the browser url and reload the page. Now all this logic has been handled for us in the react Google oauth package itself. It extracts the token from the query parameters and gives us back in the form of callback function. So the flow diagram is like this If frontend redirect url Browser -> Google -> browser -- redirects to frontend page with token(using js we can get the token -- this part is handled by the react package) If backend redirect url Browser -> Google -> browser -- now browser will make a GET request to your backend server with those query parameters. In both the cases the response will come back to the browser since only the browser made the HTTP request. Then the browser makes the decision to either show the frontend page or make a GET call to backend It's better to use the frontend url because it will show the UI to the user. If you are interested in trying with the backend redirect url, it would be a good Learning for you if you do some research on how to do it and also use the insights I have given above. It would be really fruitful. One small tip you should do without using any package on the frontend and backend remains the same. Happy learning.😊😊
pls upload the video for refresh token too, this was so helpful.Thank you so much
Happy to help you and thanks for your input I will make the video once I get time. Happy learning 🎈😁
Do the explicit one to although you explained in a very good way just to complete the implicit and explicit videos please make another one too
Sure Goligoo. Thanks for the suggestion ☺️
Thanks
bro , why am i getting error redirect uri mismatch, in redirect uri we need to mention the route of backend or frontend
We have to mention the frontend url
@@EfficientDevJourney why it shouldnt be backend?
Actually it can be any but if you have it to be your backend it would be tricky to handle. So when Google responds with successful authorisation it sends us back a redirect response(HTTP redirect response). This redirect response will contain the redirect url(what we have given in the cloud console along with some query parameters such as the token). Now when the browser reads this redirect response it's gonna load that into the browser url and reload the page. Now all this logic has been handled for us in the react Google oauth package itself. It extracts the token from the query parameters and gives us back in the form of callback function. So the flow diagram is like this
If frontend redirect url
Browser -> Google -> browser -- redirects to frontend page with token(using js we can get the token -- this part is handled by the react package)
If backend redirect url
Browser -> Google -> browser -- now browser will make a GET request to your backend server with those query parameters.
In both the cases the response will come back to the browser since only the browser made the HTTP request. Then the browser makes the decision to either show the frontend page or make a GET call to backend
It's better to use the frontend url because it will show the UI to the user.
If you are interested in trying with the backend redirect url, it would be a good Learning for you if you do some research on how to do it and also use the insights I have given above. It would be really fruitful. One small tip you should do without using any package on the frontend and backend remains the same. Happy learning.😊😊
I didn't mean to strike out anything but UA-cam did some formatting to my text. Just read the text as it is.