question

Thor Alexander avatar image
Thor Alexander asked

Google Authentication for Unreal Desktop Game,Google authentication for an unreal desktop game

Hello,

I'm trying to integrate Google Authentication with Playfab in my Unreal desktop game. I will describe the approaches I consider and the problems I found but please let me know if there is a guide somewhere or someone is already doing this in another way.

First approach: Server Auth Code. I couldn't find information about performing this operation outside of android. I'm not sure if we are talking about a normal code with offline access (the google docs are not so clear to me) but if so I don't know how to configure the redirect url and such, since the code will be exchanged in playfab servers.

Second approach: client side authentication. This was my plan: start a HTTP server in my game ((https://docs.unrealengine.com/en-US/API/Runtime/HttpServer/index.html), launch a browser to the google authorization endpoint and set the HTTP server listen address as the redirect uri. Get back an access token and call LoginWithGoogle with the access token (I cannot do it with the sdk but I can make the request directly). I want to confirm this is an acceptable solution, and I also have a problem with this approach (this is more like unreal question but I'm going to mention here to have the full picture): It seems I have no way to recover the piece of the url that starts with the # sign, which is how oauth2 builds the redirect url with the access token.

Thanks!

,

Hello,

I'm trying to integrate Google Authentication with Playfab in my Unreal desktop game. I will describe the approaches I consider and the problems I found but please let me know if there is a guide somewhere or someone is already doing this in another way.

First approach: Server Auth Code. I couldn't find information about performing this operation outside of android. I'm not sure if we are talking about a normal code with offline access (the google docs are not so clear to me) but if so I don't know how to configure the redirect url and such, since the code will be exchanged in playfab servers.

Second approach: client side authentication. This was my plan: start a HTTP server in my game ((https://docs.unrealengine.com/en-US/API/Runtime/HttpServer/index.html), launch a browser to the google authorization endpoint and set the HTTP server listen address as the redirect uri. Get back an access token and call LoginWithGoogle with the access token (I cannot do it with the sdk but I can make the request directly). I want to confirm this is an acceptable solution, and I also have a problem with this approach (this is more like unreal question but I'm going to mention here to have the full picture): It seems I have no way to recover the piece of the url that starts with the # sign, which is how oauth2 builds the redirect url with the access token.

Thanks!

Authenticationunreal
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

>> First approach: Server Auth Code.

PlayFab provides an Authorized redirect URI(https://oauth.playfab.com/oauth2/google) in this tutorial -- https://docs.microsoft.com/en-us/gaming/playfab/features/authentication/platform-specific-authentication/google-sign-in-unity. This tutorial is based on the Unity Engine and the sample is built with the Android Platform. Please let us know if it can help you.

>> Second approach: client side authentication.

As you said, the second approach is the more proven method. You can refer to the doc -- https://docs.microsoft.com/en-us/gaming/playfab/features/authentication/platform-specific-authentication/google-html5 to learn about how to set up the PlayFab authentication using Google in the web page. After testing, the “AccessToken” field still can be passed to the LoginWithGoogleAccount API, even if it has been removed in the SDK and API reference. As a workaround, you may need to add it to the SDK on your own. About this situation, the “AccessToken” has been removed in the API reference and SDK but still is used in the tutorial. We will feedback it to the engineering team.

Besides, I’m not sure what is “the url that starts with the # sign”. Could you please clarify it?

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thor Alexander avatar image Thor Alexander commented ·

Thanks for you answers!

Regarding the first approach: it seems oauth.playfab.com is down or something right now, I'll try it later. But I still cannot understand the full flow, can you mention the steps I need to take in oauth terms?. If I'm understanding you correctly I first need to redirect the user to the google login page asking for an offline code and redirect_uri to playfab. But then.. how do we continue here?

Regarding the second approach: I meant after google login the redirect url is appended with `#access_token=....`, I can parse that in a browser, but I think by design this doesn't reach the server, so I'm kind of stuck (maybe there is a way to do this with the internal unreal browser, I don't know).

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Thor Alexander commented ·

For the first approach, we didn't do successfully test on the web page. If in the android device, PlayFab OAuth server would return a token. And the application would log the player in automatically. For the 2nd approach, in Unity, we can invoke the JS native plugin in the WebGL build. If your game is a client application maybe you need to use an external browser to implement the next process. More advanced questions about how invoke an external browser in Unreal, you can try to contact the Unreal supports for professional help.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]