전체적인 흐름이 구글과 매우 유사하다.
GET <https://accounts.spotify.com/authorize>
GET <https://accounts.spotify.com/authorize>?
client_id={client_id}&
response_type=code&
redirect_uri={redirect uri}&
scope=user-read-private user-read-email&
state=12345
https://{redirect uri}?code={인가 code 정보}&state={}
POST <https://accounts.spotify.com/api/token>
POST <https://accounts.spotify.com/api/token>
Content-Type: application/x-www-form-urlencoded
code={인가 code 정보}
client_id={client_id}&
client_secret={client_secret}&
redirect_uri={redirect uri}&
grant_type=authorization_code
핵심은 Content-Type
이 application/x-www-form-urlencoded
이다. google과 동일한데 restTemplate.postForObject 메소드를 적용하면 지원하지 않는 media-type으로 415
코드를 던진다. 우리 프로젝트에서는 프론트에서 token 까지 생성하여 전달받을 예정이기 때문에 간단히 조사하였다.
{
"access_token": "{access_token}",
"token_type": "Bearer",
"scope": "user-read-email user-read-private",
"expires_in": "3600",
"refresh_token": "{refresh_token}"
}