개발

TISTORY API 사용하기

Dev Aaron 2023. 11. 23. 22:31
반응형

1. 앱등록

https://www.tistory.com/guide/api/manage/register

상기 사이트에서 앱 등록을 한다.
redirect url은 https://localhost 를 입력

 

Tistory

좀 아는 블로거들의 유용한 이야기

www.tistory.com

앱 등록 후 App ID, Secret Key를 얻는다.

2. Authentication Code 발급

https://www.tistory.com/oauth/authorize?
  client_id={client-id}
  &redirect_uri={redirect-uri}
  &response_type=code

client-id: App ID

redirect_uri: 앱 등록 시 등록한 "https://localhost"

팝업에서 허가하기 누르면 redirect url로 이동하는데,
입력한 https://localhost 는 유효하지 않기 때문에 페이지가 올바르게 뜨지 않는다.
하지만 페이지가 중요한게 아니라, 주소창에서 확인되는 주소가 핵심이다.

주소에 query param으로 code가 넘어온다.

3. Access Token 얻기

아래와 같이 rest api를 사용하여 access token을 얻는다.

https://www.tistory.com/oauth/access_token?
  client_id={client-id}
  &client_secret={client-secret}
  &redirect_uri={redirect-uri}
  &code={code}
  &grant_type=authorization_code
반응형