# Invalid redirect: http://127.0.0.1:5000/oauth/callback (4,700)

**URL:** <https://devforum.zoom.us/t/invalid-redirect-http-127-0-0-1-5000-oauth-callback-4-700/95012>\
**Category:** API and Webhooks\
**Created:** [September 13, 2023, 11:56am UTC](https://devforum.zoom.us/t/invalid-redirect-http-127-0-0-1-5000-oauth-callback-4-700/95012 "2023-09-13T11:56:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![johny.achkar01](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@johny.achkar01](https://devforum.zoom.us/u/johny.achkar01)\
**Post date:** [September 13, 2023, 11:56am UTC](https://devforum.zoom.us/t/invalid-redirect-http-127-0-0-1-5000-oauth-callback-4-700/95012/1 "2023-09-13T11:56:13Z")

</div>

i am new to zoom and i appreciate some help. i am building a web application on flask-python and one of the functionalities is to connect doctors to patients through a teleconsultation.  
i am trying to get a token so i went over the Oauth process. the web app is under development so i did not publish it in Marketplace. i am getting invalid redirect url 4,700 for my local url.  
this is my server side code:  
@app.route(‘/oauth/callback’)  
def oauth\_callback():  
received\_state = request.args.get(‘state’)  
if received\_state !=STATE:  
return “Invalid state parameter, possible CSRF attack.”  
code = request.args.get(‘code’)  
credentials = f"{CLIENT\_ID}:{CLIENT\_SECRET}"  
base64\_credentials = base64.b64encode(credentials.encode()).decode()

```
headers={
    'Authorization':base64_credentials,
    'Content-Type': 'application/x-www-form-urlencoded'
}
payload={
    'code':code,
    'grant_type':'authorization_code',
    'redirect_uri':REDIRECT_URI,

}
response = requests.post(TOKEN_URL,headers=headers,data=payload)
if response.status_code==200:
    access_token = response.json().get('access_token')
    return f"Access token received:{access_token}"
else:
    return f"Error:{response.status_code},{response.text}"

```

this is my url redirect : [http://127.0.0.1:5000/oauth/callback](http://127.0.0.1:5000/oauth/callback)

---

<div class="post-metadata">

**Author:** ![michael.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael.zoom/32/37213_2.png) [@michael.zoom](https://devforum.zoom.us/u/michael.zoom)\
**Post date:** [September 13, 2023, 8:35pm UTC](https://devforum.zoom.us/t/invalid-redirect-http-127-0-0-1-5000-oauth-callback-4-700/95012/2 "2023-09-13T20:35:03Z")

</div>

Hey @johny.achkar01 welcome to the Zoom dev platform!

Can you try a redirect URL over HTTPS? Something like [ngrok](https://ngrok.com/) should help make this easy to setup. Be sure to add this domain to your allow list in the app.

---

<div class="post-metadata">

**Author:** ![johny.achkar01](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@johny.achkar01](https://devforum.zoom.us/u/johny.achkar01)\
**Post date:** [September 14, 2023, 10:31am UTC](https://devforum.zoom.us/t/invalid-redirect-http-127-0-0-1-5000-oauth-callback-4-700/95012/3 "2023-09-14T10:31:56Z")

</div>

Thank you Michael for your feedback. i used ngrok as you suggested in your above feedback.  
now i am getting a new error “Error:400,{“reason”:“Invalid client\_id or client\_secret”,“error”:“invalid\_client”}  
althought i checked my client id and client secret and they look ok.  
appreciate any help:  
this is my code:  
REDIRECT\_URI =“[https://4f18-37-186-45-147.ngrok-free.app/oauth/callback](https://4f18-37-186-45-147.ngrok-free.app/oauth/callback)”  
@app.route(‘/create\_meeting’, methods=[‘GET’, ‘POST’])  
def create\_meeting():  
topic = “Create Meeting”  
patient\_name = session.get(‘pt\_name\_booked’)  
doctor\_email = session.get(‘doc\_email’)  
slot\_duration = session.get(‘slot\_duration’)  
start\_time = session.get(‘start\_time’)  
current\_timestamp = round(time.time())  
iat = current\_timestamp  
exp = iat + (60 \* 60 \* 2)  
authorization\_url = f”{AUTHORIZE\_URL}?response\_type=code&client\_id={CLIENT\_ID}&redirect\_uri={REDIRECT\_URI}"  
print(authorization\_url)  
return f"Click here to authorize Zoom "

@app.route(‘/oauth/callback’)  
def oauth\_callback():  
code = request.args.get(‘code’)  
credentials = f"{CLIENT\_ID}:{CLIENT\_SECRET}"  
base64\_credentials = base64.b64encode(credentials.encode()).decode()

```
headers={
    'Authorization':base64_credentials,
    'Content-Type': 'application/x-www-form-urlencoded'
}
payload={
    'code':code,
    'grant_type':'authorization_code',
    'redirect_uri':REDIRECT_URI,

}
response = requests.post(TOKEN_URL,headers=headers,data=payload)
if response.status_code==200:
    access_token = response.json().get('access_token')
    return f"Access token received:{access_token}"
else:
    return f"Error:{response.status_code},{response.text}"

```

---

<div class="post-metadata">

**Author:** ![johny.achkar01](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@johny.achkar01](https://devforum.zoom.us/u/johny.achkar01)\
**Post date:** [September 15, 2023, 5:18am UTC](https://devforum.zoom.us/t/invalid-redirect-http-127-0-0-1-5000-oauth-callback-4-700/95012/4 "2023-09-15T05:18:26Z")

</div>

Hello, i am still getting this error : Error:400,{“reason”:“Invalid client\_id or client\_secret”,“error”:“invalid\_client”} and not being able to solve it .  
i appreciate any support.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [September 17, 2024, 8:55pm UTC](https://devforum.zoom.us/t/invalid-redirect-http-127-0-0-1-5000-oauth-callback-4-700/95012/5 "2024-09-17T20:55:01Z")

</div>

Closed on September 17, 2024, 8:55pm UTC

This topic was automatically closed 368 days after the last reply. New replies are no longer allowed.
