Class DropboxAuthorizationController

java.lang.Object
org.apache.clusterbr.zupportl5.controller.DropboxAuthorizationController

@RestController @RequestMapping("/api/dropbox") public class DropboxAuthorizationController extends Object

REST-API Endpoints --

  • GET /api/dropbox/start-auth: Initiates Dropbox OAuth-2 authorization-flow by generating and returning the authorization URL.
  • GET /api/dropbox/oauth2/callback: Handles the authorization callback, retrieves the refresh token, and stores it securely.

Implementing the OAUTH-2 AUTHORIZATION-FLOW as required by Dropbox

  1. ADMIN user triggers the authorization process by visiting /api/dropbox/start-auth.
  2. The ADMIN is redirected to Dropbox's authorization page, to log-in, once logged-in the Authorization workflow continues the next-step.
  3. Dropbox sends the CODE to the following endpoint of the APP: /api/dropbox/oauth2/callback; the callback(code) function receives the CODE sent by Dropbox.
  4. Then the application exchanges the CODE with the Dropbox-api requesting for-a FRESH-TOKEN. The APP saves the FRESH-TOKEN securely.
  5. Then the application exchanges the CODE with the Dropbox-api requesting for-a FRESH-TOKEN. The APP saves the FRESH-TOKEN.

REFRESH-TOKEN Explained

  • Purpose: Used to obtain a new access token when the current one expires.
  • Scope: Tied to the same permissions granted during initial authentication.
  • Lifespan: Long-lived (can last days, months, or indefinitely depending on the provider).
  • Does Not Expire Quickly: It stays valid as long as the user hasn’t revoked the authorization.

ACCESS-TOKEN Explained

  • Purpose: Grants temporary access to a specific API or resource.
  • Scope: Limited to the permissions granted during authentication (e.g., read/write files).
  • Lifespan: Short-lived (usually minutes to hours).
  • Expires Quickly: Requires renewal after expiration.
Dropbox API v2
Dropbox OAuth Guide

UML Diagrams:

UML CLASS Diagram

UML USECASE Diagram

UML SEQ Diagram

UML ACTIVITY Diagram

Since:
2024-1108
Author:
arcbrth@gmail.com
  • Constructor Details

    • DropboxAuthorizationController

      @Autowired public DropboxAuthorizationController(DropboxTokenService dropboxTokenService)
  • Method Details

    • startAuthorization

      @GetMapping("/start-auth") public org.springframework.http.ResponseEntity<String> startAuthorization()

      Entry end-point to initiate the Dropbox Authorization.

      https://server:port/api/dropbox/oauth2/callback

      https://www.dropbox.com/developers/documentation/http/documentation#oauth2-authorize

    • handleCallback

      @GetMapping("/oauth2/callback") public org.springframework.http.ResponseEntity<String> handleCallback(@RequestParam Map<String,String> params, jakarta.servlet.http.HttpServletRequest request)