Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by chatgray · Jun 26, 2017 at 08:04 AM · google play gamesloginnodejs

How can I verify android app's GPGS token on my node.js server using passport

I've developed a game client(Android) and server using Unity and node.js.

The log-in function of the server is implemented using passport.js. It was simple, so I didn't worry about anything. I was supposed to implement log-in feature in my game by popping up the in app browser.

But it turns out android games need to use "Google Play Game Service" to log in to Google. I confused how to use passport.js in this case.

The sequence of the Google OAuth2.0 login I know is roughly as follows.

  1. Game client request "authenticate" to GPGS using "google-games-plugin-for-unity"

  2. If login success, game client can get "Authorization Code" using "GetIdToken()" api.

  3. Game client send this token to my game server.

  4. Game server verify the token(from step3) through Google api service.

  5. If verifying success, my server can get user infos and access token.

  6. Fully login complete.

I am wondering how to implement step3 and onwards using passport.js. Can I use passport.js to implement this with only "GoogleStrategy" configuration? How?

Comment
Add comment
10 |3000 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
0

Answer by chatgray · Jun 27, 2017 at 05:46 AM

I found a solution myself. There was something wrong what I knew. The sequence of the Google OAuth2.0 is right as above except one thing.

I thought I could get the "Authorization Code" by using "GetIdToken()" api of "google-games-plugin-for-unity". But, if I wanna get the "Authorization Code", I had to use "GetServerAuthCode()", not to use "GetIdToken()". This description was in ReadME of "google-games-plugin-for-unity" github. It was my fault that I didn't read it in detail.

IdToken and AuthCode are not same, it is the part what I didn't know correctly. (See "Retrieving server authentication codes" of https://github.com/playgameservices/play-games-plugin-for-unity#retrieving-server-authentication-codes )

Now, game client can get "Authorization Code" well using "GetServerAuthCode()", and game client make url to send this token to game server as bellow.(using get, but google recommend using post)

var _url = "YOUR://WEBAPP/REDIRECTION/URL?code="+ PlayGamesPlatform.Instance.GetServerAuthCode();

Game server will get this url and the server can use "passport.authenticate" which is the same way when it get redirection url from web browser.

If your both user auth info(android app and web app) are registered in same Google API console project, they will share auth info and the login procedure will perform same like using browser case.

Comment
Add comment · Share
10 |3000 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

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.

Follow this Question

Answers Answers and Comments

67 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

When I start my game on Android this crashes (google play problem) 0 Answers

After updating unity to 2020.3.33 my google play services not logged in. 1 Answer

Google Play services authentication issue 0 Answers

Sign in/out in GPG 0 Answers

How to view detailed errors related to Google Play Games APIs 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges