카카오 메시지 rest api 질문입니다

from flask import Flask, render_template, redirect, url_for, request
import requests
import json

app = Flask(name)

@app.route(’/’)
def hello_world():
return render_template(‘index.html’)
@app.route(’/oauth’)
def oauth():
code = str(request.args.get(‘code’))
url = "https://kauth.kakao.com/oauth/token"
payload = “grant_type=authorization_code&client_id=43e3daf58dd14d049001ebdbd6538f58&redirect_uri=http://127.0.0.1:5000/oauth&code=”+str(code)
headers = {
‘Content-Type’: “application/x-www-form-urlencoded”,
‘Cache-Control’: “no-cache”,
}
response = requests.request(“POST”,url,data=payload,headers=headers)
access_token = json.loads(((response.text).encode(‘utf-8’)))[‘access_token’]

url = "https://kapi.kakao.com/v1/user/signup"
headers.update({'Authorization' : "Bearer " + str(access_token)})
response = requests.request("POST",url,headers=headers)

url = "https://kapi.kakao.com/v1/user/me"
profile_request = requests.get("https://kapi.kakao.com/v2/user/me", headers={"Authorization" : f"Bearer {access_token}"},
        )
profile_json = profile_request.json()
kakao_account = profile_json.get("kakao_account")
email = kakao_account.get("email", None)
kakao_id = profile_json.get("id")

txt = 'hello kakao'

req_url = 'https://kapi.kakao.com/v2/api/talk/memo/default/send'
headers = {"Content-Type": "application/json","Content-Type": "x-www-form-ur;emcoded","Authorization": 'Bearer ' + str(access_token)}
req = requests.post(req_url, headers=headers, params=make_message(txt))

if req.status_code == 200:
    return ("sucess")
else:
    return (req.text)

def make_message(text):
temp = {
“object_type”: “text”,
“text”: text,
“link”: {
“web_url”: “https://developers.kakao.com”,
“mobile_web_url”: “https://developers.kakao.com
},
“button_title”: “바로 확인”,
}

return {"template_object":json.dumps(temp)}

if name == ‘main’:
app.run(debug=True)

위에 작성한 코드로 실행하였는데
{“msg”:“insufficient scopes.”,“code”:-402,“api_type”:“TALK_MEMO_DEFAULT_SEND”,“required_scopes”:[“talk_message”],“allowed_scopes”:[“age_range”,“birthday”,“account_email”,“gender”,“profile”]}
이렇게 권한이 없다고 나옵니다…

엑세스 토큰도 문제 없는것 같은데 뭐가 문제인지 모르겠습니다 ㅜㅜ

메시지 전송을 위한 추가항목에 동의를 받지 못해 발생하는 에러입니다.
아래토픽의 2번항목을 참고하시기 바랍니다.

이제 봐서 죄송합니다.
먼저 답변드려서 감사합니다.
말씀하신대로 추가동의 api를 가져와서
url = “https://kauth.kakao.com/oauth/authorize?client_id={REST_API_KEY}&redirect_uri=http://127.0.0.1:5000/oauth&response_type=code&scope=talk_message

headers = {
    'Content-Type': "application/x-www-form-urlencoded",
    'Authorization': "Bearer " + str(access_token),
}

response = requests.get(url,headers=headers)

이런식으로 작성해서 적용해도 해결 되지가 않습니다. ㅜㅜ 제가 아직 처음 api를 써봐서 적용하는게 맞는지 잘 모르겠습니다.

위 요청으로 받은 응답이 어떻게 나왔나요?
혹시 위 요청 이후 다시 나에게 보내기를 해보셨나요?

위에 주소값에 들어가니까 동의항목이 뜨더라고 해결되었습니다. 감사합니다