Actual source code: googleobtainrefreshtoken.c

  1: /*
  2:      Obtains a refresh token that you can use in the future to access Google Drive from PETSc code

  4:      Guard the refresh token like a password.

  6:      You can run PETSc programs with -google_refresh_token XXXX where XXX is the refresh token to access your Google Drive

  8: */

 10: #include <petscsys.h>

 12: int main(int argc, char **argv)
 13: {
 14:   char access_token[512], refresh_token[512];

 16:   PetscFunctionBeginUser;
 17:   PetscCall(PetscInitialize(&argc, &argv, NULL, NULL));
 18:   PetscCall(PetscGoogleDriveAuthorize(PETSC_COMM_WORLD, access_token, refresh_token, sizeof(access_token)));
 19:   PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Your Refresh token is %s\n", refresh_token));
 20:   PetscCall(PetscFinalize());
 21:   return 0;
 22: }

 24: /*TEST

 26:    build:
 27:      requires: ssl

 29:    test:
 30:      TODO: determine how to run this test without going through the browser

 32: TEST*/