Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • General Discussion /
avatar image
Question by Thor Alexander · Jul 06, 2020 at 04:14 PM · Authenticationunreal

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!

Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Sarah Zhang · Jul 07, 2020 at 08:52 AM

>> 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?

Comment

People who like this

0 Show 2 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Thor Alexander · Jul 07, 2020 at 12:17 PM 0
Share

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).

avatar image Sarah Zhang Thor Alexander · Jul 17, 2020 at 07:05 AM 0
Share

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.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    2 People are following this question.

    avatar image avatar image

    Related Questions

    Connecting to a Dedicated Server 1 Answer

    Can't login with google because the google play games services plugin for unity is returning an empty auth code 1 Answer

    Game Center vs DeviceID ? 1 Answer

    WebGL Generate CustomId 2 Answers

    How to log into original account on reinstall or new device? 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges