In Java how can i avoid or simplify reirecting the browser for code

17 views
Skip to first unread message

noor.gani

unread,
Sep 25, 2023, 5:26:50 AM9/25/23
to google-ca...@googlegroups.com
Hi,

I am a java developer and integrating google calendar api, i am able to get the events from google but i want to  simplify this process so that the user won't have to do  copy-and-paste stuff for the authorization code to be received to get the access token? Currently all I know is that I will need to provide a callback url, but every time when the token expires we have to open the browser for that.

My Question is can I avoid this by opening the browser or simplify this.

My code is :

GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
.setAccessType("offline").build();
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build();
Credential credential = new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");

Best Regards,
Noor.

Paulo Perez

unread,
Sep 25, 2023, 6:47:38 AM9/25/23
to google-ca...@googlegroups.com
Hi Noor,

Sorry my delay, I`ll very pleasure to give assistance, but in this
moment I'm very busy, end of the day, I send you how I made my
development :)

Paulo

Em seg., 25 de set. de 2023 às 06:26, noor.gani
<noor.g...@gmail.com> escreveu:
> --
> You received this message because you are subscribed to the Google Groups "Google Calendar API" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to google-calendar...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/google-calendar-api/CAPt0F9HssZRP%2Bxhin0XPhoyj5UjbkLZiFqT-BL72B6iMDpFbFg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages