CoderGuru
CoderGuru

Reputation: 49

Store Data on Users Google Account

I have used This to create a login on my site, with the onSignIn function, signOut function, and auth2.isSignedIn.get() function (which checks if you are already signed in).

Now is there a way if which I can get a piece of data from the site, e.g. a special value from an input that the user has typed, and store it on the user (google user who logged in)'s google account, preferably as a key, like localStorage?

A minor start here:

document.getElementById("userText").addEventListener("change", function() {
    var data = document.getElementById("userText").value;
    
    googleAccount.userData = data; // Change this Line
});
<input type = "text" id = "userText">

Upvotes: 2

Views: 879

Answers (1)

Peter B
Peter B

Reputation: 24280

That is not possible, it's just not within the goals and purposes of an(y) authentication provider.

Have you thought of:

  • How would Google keep "your" piece of data secure and separate from other sites that would try to do the same for that user?
  • How would Google deal with the possibly Gigabytes of data that it would have to store (per user, for multiple sites combined) within days after this feature would be introduced?

The way this is usually done is by creating a database / datastore, that you then maintain and make backups of (and possibly pay for) in which you store data for each user, using some User ID as a "key".

Upvotes: 1

Related Questions