question

cartellonegerardo avatar image
cartellonegerardo asked

How to add a username an account made through google sign in.

After long struggles i finally managed to make "google sign in" work with playfab. The only issue is accounts created with "google sign in" don't have usernames. In my game the username is the way people find each other to add each other as friends.

I saw that playfab seemed to have this function: "AddUsernamePassword" that was supposetivly exactlly for the purpose I needed it for but it doesn't seem to work. I have to put an e-mail and a password asides from the username.

-For the password I just put something random since the accounts don't need a password people log in via google sign in.

-For the e-mail I put the g-mail of the user. But it doesn't work it tells me that the e-mail already exists and if I remove the e-mail it tells me it needs an e-mail.

https://learn.microsoft.com/en-us/rest/api/playfab/client/account-management/add-username-password?view=playfab-rest

I'm not sure how i'm going to go about giving my users that made their accounts via google sign in usernames or anything so they are identifiable in a human friendly way?

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

·
Gosen Gao avatar image
Gosen Gao answered

After a player sign in with Google, you can call Google Api to get the player's Google usernames, then you can use Account Management - Update User Title Display Name - REST API (PlayFab Client) | Microsoft Learn to set it to the Display Name.

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.

cartellonegerardo avatar image cartellonegerardo commented ·

yes but as far as i know the display name can't be used to find the player? If a player wants to search the database to add that player as a friend? since it doesn't have to be unique. Meaning only way for players to add each other would be from knowing their id: meaning the long code.

0 Likes 0 ·
Gosen Gao avatar image Gosen Gao cartellonegerardo commented ·

You can add a player as a friend by Display Name with API Friend List Management - Add Friend - REST API (PlayFab Client) | Microsoft Learn. And the Display Name is unique, as long as you don't enable 'Allow non-unique player display names' in title settings. Also, the Google username is unique, and if the Display Name is based on it, it should be unique.

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.