Search in sources :

Example 1 with DbxStandardSessionStore

use of com.dropbox.core.DbxStandardSessionStore in project dropbox-webhooks-spring-boot-example by zeldan.

the class DropboxService method finishAuthAndSaveUserDetails.

public void finishAuthAndSaveUserDetails(final HttpSession session, final Map<String, String[]> parameterMap) throws Exception {
    final DbxSessionStore csrfTokenStore = new DbxStandardSessionStore(session, dropboxConfigProp.getSessionStore().getKey());
    final DbxAuthFinish authFinish = auth.finishFromRedirect(dropboxConfigProp.getRedirectUri(), csrfTokenStore, parameterMap);
    final String accessToken = authFinish.getAccessToken();
    final DbxClientV2 client = new DbxClientV2(requestConfig, accessToken);
    final String userId = authFinish.getUserId();
    final ListFolderResult listFolderResult = client.files().listFolderBuilder("").withRecursive(true).start();
    saveAccessTokenAndActualCursor(userId, accessToken, listFolderResult);
}
Also used : DbxSessionStore(com.dropbox.core.DbxSessionStore) DbxClientV2(com.dropbox.core.v2.DbxClientV2) ListFolderResult(com.dropbox.core.v2.files.ListFolderResult) DbxAuthFinish(com.dropbox.core.DbxAuthFinish) DbxStandardSessionStore(com.dropbox.core.DbxStandardSessionStore)

Example 2 with DbxStandardSessionStore

use of com.dropbox.core.DbxStandardSessionStore in project dropbox-webhooks-spring-boot-example by zeldan.

the class DropboxService method startAuth.

public String startAuth(final HttpSession session) {
    final DbxSessionStore csrfTokenStore = new DbxStandardSessionStore(session, dropboxConfigProp.getSessionStore().getKey());
    final DbxWebAuth.Request authRequest = DbxWebAuth.newRequestBuilder().withRedirectUri(dropboxConfigProp.getRedirectUri(), csrfTokenStore).build();
    return auth.authorize(authRequest);
}
Also used : DbxSessionStore(com.dropbox.core.DbxSessionStore) DbxStandardSessionStore(com.dropbox.core.DbxStandardSessionStore) DbxWebAuth(com.dropbox.core.DbxWebAuth)

Example 3 with DbxStandardSessionStore

use of com.dropbox.core.DbxStandardSessionStore in project dropbox-sdk-java by dropbox.

the class DropboxAuth method getSessionStore.

// -------------------------------------------------------------------------------------------
private DbxSessionStore getSessionStore(final HttpServletRequest request) {
    // Select a spot in the session for DbxWebAuth to store the CSRF token.
    HttpSession session = request.getSession(true);
    String sessionKey = "dropbox-auth-csrf-token";
    return new DbxStandardSessionStore(session, sessionKey);
}
Also used : HttpSession(javax.servlet.http.HttpSession) DbxStandardSessionStore(com.dropbox.core.DbxStandardSessionStore)

Aggregations

DbxStandardSessionStore (com.dropbox.core.DbxStandardSessionStore)3 DbxSessionStore (com.dropbox.core.DbxSessionStore)2 DbxAuthFinish (com.dropbox.core.DbxAuthFinish)1 DbxWebAuth (com.dropbox.core.DbxWebAuth)1 DbxClientV2 (com.dropbox.core.v2.DbxClientV2)1 ListFolderResult (com.dropbox.core.v2.files.ListFolderResult)1 HttpSession (javax.servlet.http.HttpSession)1