Sharing data between apps

Hi,


If the upload was successful the Upload call will return a "TGDriveItem", if not "nil" is returned.

I have a buttonclick event that uploads a file to google drive. the code is here:
void __fastcall TMainForm::UploadGDriveBTNClick(TObject *Sender)
{
  bool ValidToken=false;
  if (!TMSFMXCloudGDrive1->App->Key.IsEmpty()) {
    // load tokens from registry
    TMSFMXCloudGDrive1->LoadTokens();
    // test if the access token is still accepted
    ValidToken=TMSFMXCloudGDrive1->TestTokens();
    if (!ValidToken) { // when not, try to get a new access token with the refresh token if not acc then
      ValidToken= TMSFMXCloudGDrive1->RefreshAccess();
      if (!ValidToken) {// when no new access token can be obtained, do new authentication
        TMSFMXCloudGDrive1->DoAuth();
      }
    }
  }

  ValidToken= TMSFMXCloudGDrive1->RefreshAccess();
  if (ValidToken) {
    if (TMSFMXCloudGDrive1->Upload(0, MyFileFullName))
      ShowMessage("The file is uploaded successfully!");
    else ShowMessage("The file is not uploaded! Try again later please!");
  }
}

It seems that I have to click this button twice to get the file uploaded. The first click pops-up authbrower saying "My App would like to: have offline access" with two buttons "Deny" and "allow". Then I have to click "Allow" to get google drive connected, then second button click starts to upload my file.
Is it a way to just have one click and skip this authbrowser if I have my token?
Thanks!

As long as the access token is valid, the TestTokens call should return true and the pop up requesting authorization should not appear.

Can you please make sure the token was saved and then loaded correctly and that it is still valid?

I don't know how to check if my token is saved. here is the code to save it.

void __fastcall TMainForm::TMSFMXCloudGDrive1ReceivedAccessToken(TObject Sender)
{
  TTMSFMXCloudGDrive
Ptr;
//   begin Authenticated := true;
  if (Sender==TMSFMXCloudGDrive1) {
//  if (typeid(Sender) == typeid(TTMSFMXCloudGDrive)) {
    Ptr=(TTMSFMXCloudGDrive*) Sender;
    Ptr->SaveTokens();
  };

Depending on where you persist your tokens, you should either see token information appear in an INI file or in the registry. Did you check this? Did you set the settings properly for where to persist the tokens via TMSFMXCloudGDrive.PersistTokens?

I have a default settings for TMSFMXCloudGDrive.PersistTokens. That is plIniFile. But I don't know what is the default ini file in my windows system. Where is the file on android device. Should I change it to registry?

You need to set at least a filename for the INI file and the section to use within this INI file. This is explained in the PDF developers guide.