xref: /petsc/src/sys/webclient/tutorials/googleobtainrefreshtoken.c (revision c4762a1b19cd2af06abeed90e8f9d34fb975dd94)
1 
2 /*
3      Obtains a refresh token that you can use in the future to access Google Drive from PETSc code
4 
5      Guard the refresh token like a password.
6 
7      You can run PETSc programs with -google_refresh_token XXXX where XXX is the refresh token to access your Google Drive
8 
9 */
10 
11 #include <petscsys.h>
12 
13 int main(int argc,char **argv)
14 {
15   PetscErrorCode ierr;
16   char           access_token[512],refresh_token[512];
17 
18   ierr = PetscInitialize(&argc,&argv,NULL,NULL);if (ierr) return ierr;
19   ierr = PetscGoogleDriveAuthorize(PETSC_COMM_WORLD,access_token,refresh_token,sizeof(access_token));CHKERRQ(ierr);
20   ierr = PetscPrintf(PETSC_COMM_WORLD,"Your Refresh token is %s\n",refresh_token);CHKERRQ(ierr);
21   ierr = PetscFinalize();
22   return ierr;
23 }
24 
25 /*TEST
26 
27    build:
28      requires: ssl
29 
30    test:
31      TODO: determine how to run this test without going through the browser
32 
33 TEST*/
34 
35 
36