0

I have a specific google account and a file on it. I want to modify the file from a few android devices without having to log in to this account (User don't have a permission to use this account). I also don't want user to access this file manually (only with the app), so the file can't be shared.

I don't want to share login and password, because it's not safe. I came with idea to share encrypted token, but it expires really fast, so i wanted to share an encrypted refresh token, but when I want to obtain it, problems appear. I have an android.accounts.Account object and I probably should be able to get refresh token with android.accounts.AccountManager, like this:

String refreshToken = accountManager.getUserData(account, "refreshToken");

but I can't do it, because of this:

java.lang.SecurityException: uid cannot get user data for accounts of type: com.google

Is it a good idea to share refresh token? How can I get it? If not, how to do it?

MSZ
  • 51
  • 5
  • 2
    Have you considered using a service account? – Linda Lawton - DaImTo Aug 23 '21 at 13:08
  • It's possible to do it this way. I tested it and it works. I stored service account key as string KEY `GoogleCredential gc = GoogleCredential.fromStream(new ByteArrayInputStream(KEY.getBytes()));`. Anyway, it's not very elastic. Sharing refresh token for google account would be a lot easier I think. – MSZ Aug 23 '21 at 20:23
  • 1
    You said that you were only accessing "a specific google account" granting a service account access to that drive account and then running everything though the drive account is the best method for this. Sharing a refresh token with others is NOT a very secure method. https://youtu.be/UTTTtwb7x7g – Linda Lawton - DaImTo Aug 24 '21 at 07:20

0 Answers0