34 lines
1.0 KiB
Java
34 lines
1.0 KiB
Java
|
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 String code) {
|
||
|
return ResponseEntity.ok(spotifyService.authorize(code));
|
||
|
}
|
||
|
}
|