Bat/src/main/java/cc/fascinated/bat/controller/SpotifyController.java

34 lines
1.1 KiB
Java
Raw Normal View History

2024-06-28 02:01:21 +00:00
package cc.fascinated.bat.controller;
import cc.fascinated.bat.service.SpotifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @author Fascinated (fascinated7)
*/
@RestController
@RequestMapping(value = "/spotify")
public class SpotifyController {
private final SpotifyService spotifyService;
@Autowired
public SpotifyController(SpotifyService spotifyService) {
this.spotifyService = spotifyService;
}
/**
* A GET request to authorize the user with Spotify.
*
* @return the response entity
*/
@GetMapping(value = "/callback")
public ResponseEntity<String> authorizationCallback(@RequestParam(required = false) String code) {
2024-06-28 02:01:21 +00:00
return ResponseEntity.ok(spotifyService.authorize(code));
}
}