정보&강의 네이버 밴드 오픈 API 토큰 발급 소스
- 운영자
- 1049
- 0
네이버 밴드 오픈 API 센터
https://developers.band.us/develop/guide/api
https://developers.band.us/develop/myapps/list
지난번 티스토리 액세스 토큰을 발급받는 방법을 찾아봤는데, 오늘은 네이버 밴드를 알아보겠습니다.
방식은 티스토리와 비슷합니다.
코드를 발급받고, 이후 엑세스 토큰을 발급합니다.
코드 발급후, 바로 엑세스 토큰을 발급해야 오류가 안나더군요.
# coding=utf-8 import requests import webbrowser import base64 #리다이렉트 주소입력 redirect_uri= "https://godpeople.or.kr" # 오픈API 등록후 발급 client_id ="" # Your Client_ID client_secret = "" # 1차로 코드 발급해야합니다. code = "" # 2차로 발급받은 코드로 액세스 코드를 발급받아야 합니다. access_token = "" # code get if not code: URL = f'https://auth.band.us/oauth2/authorize?response_type=code&client_id={client_id}&redirect_uri={redirect_uri}' webbrowser.open(URL) # base64 encode get clientConnect = client_id+":"+client_secret # base64 encode get clidst_base64 = base64.b64encode(bytes(clientConnect,"utf8")).decode() if not access_token: #login_token login_url = f'https://auth.band.us/oauth2/token?grant_type=authorization_code&code={code}' r = requests.get(login_url,headers={"Authorization": "Basic "+clidst_base64}) print(r.text) # {"access_token":"*****","token_type":"bearer","refresh_token":"*****","expires_in":315359999,"scope":"WRITE_POST READ_MY_PROFILE READ_POST DELETE_POST READ_ALBUM READ_PHOTO READ_BAND_PERMISSION READ_COMMENT READ_BAND_AND_USERS_LIST DELETE_COMMENT CREATE_COMMENT","user_key":"*****"} def get_info(): url = f'https://openapi.band.us/v2/profile?access_token={access_token}' r = requests.get(url, 'utf-8').json() print(r) get_info()
이런 글도 찾아보세요!
댓글 0
권한이 없습니다. 로그인