Reputation: 2112
I'm reading the google drive documentation but It's a bit unclear:
Here is how I let users authenticate to my application:
@GET
@Path("/start")
public void start(@Context HttpServletRequest request, @Context HttpServletResponse response) throws IOException {
String url = initFlow().newAuthorizationUrl().setRedirectUri("http://localhost:8080/GDriveRest/app/gdrive/finish").build();
response.sendRedirect(url);
}
@GET
@Path("/finish")
public void finish(@Context HttpServletRequest request, @Context HttpServletResponse response) throws IOException {
AuthorizationCodeFlow flow = initFlow();
flow.newTokenRequest(request.getParameter("code"));
response.sendRedirect("http://m.memegen.com/1yx6o5.jpg?"+request.getParameter("code")+"&id="+flow.getClientId());
}
private AuthorizationCodeFlow initFlow() throws IOException {
InputStream in = GDrive.class.getResourceAsStream("/client_secret.json");
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
return new GoogleAuthorizationCodeFlow.Builder(new NetHttpTransport(),
JacksonFactory.getDefaultInstance(),
clientSecrets, SCOPES).setAccessType("offline").build();
}
How I can set webhooks?
Upvotes: 0
Views: 1941
Reputation: 13469
You may check this documentation on how to create webhooks. Webhooks can be delivered using different content types:
application/json
content type will deliver the JSON payload directly as the body of the POST.application/x-www-form-urlencoded
content type will send the JSON payload as a form parameter called "payload".Regarding how you can retrieve the changes for your users, you may use the push notifications that inform your application when a resource changes. To request push notifications, you need to set up a notification channel for each resource you want to watch. After your notification channels are set up, the Drive API will inform your application when any watched resource changes.
Use the
changes.watch
method to subscribe for updates to the change log. Notifications do not contain details about the changes. Instead, they indicate that new changes are available. To retrieve the actual changes, poll the change feed as described in Retrieving changes.
Hope this helps!
Upvotes: 1