Django NGROK zoom integration issue


Sign In | Zoom

Description

Error?
Invalid redirect 4,700

Hi @arsalan.9798
Thanks for reaching out to the Zoom Developer forum and welcome to our community.
Please make sure to add your Redirect URL to the Allow List as well and try again.
Hope this helps,
Elisa

1 Like

Thanks Elisa, now when hitting the callback get request with the access_code, i am getting 400,

class ZoomOAuthCallbackView(View):

def get(self, request):
    code = request.GET.get('code')
    
    token_url = 'https://zoom.us/oauth/token'

    headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Authorization': f'Basic {base64.b64encode(f"{settings.CLIENT_ID}: 
                                                          {settings.CLIENT_SECRET}".encode()).decode()}',
    }
    payload = {
        'grant_type' : 'authorization_code',
        'code' : code,
        'redirct_uri' : settings.REDIRECT_URI,
    }
    print(payload)
    response = requests.post(token_url, headers=headers, data=payload)
    
    access_token = response.json().get('access_token')

    return JsonResponse({'access_token':access_token})

getting 400 error
Kindly review if i am doing something wrong
PS i have stopped ngrok as the above is working for localhost

Hi @arsalan.9798
Can you please double check your authorization headers? Id looks like you are encoding and decoding your client id and secret.

I saw a tutorial for node JS … What it should be? Simply just client_id: secret_key ? Or any other encoding

@arsalan.9798 you just need to base64 encode your client id and client secret

I have encoded my request
def get(self, request):
code = request.GET.get(‘code’)
token_url = ‘https://zoom.us/oauth/token
headers = {
‘Content-Type’: ‘application/x-www-form-urlencoded’,
‘Authorization’: f’Basic {base64.b64encode(f"{settings.CLIENT_ID}:{settings.CLIENT_SECRET}".encode())}',
}
payload = {
‘grant_type’ : ‘authorization_code’,
‘code’ : code,
‘redirct_uri’ : settings.REDIRECT_URI,
}
response = requests.post(token_url, headers=headers, data=payload)
access_token = response.json().get(‘access_token’)
print(access_token)
return JsonResponse({‘access_token’:access_token})

These are the headers
{‘Content-Type’: ‘application/x-www-form-urlencoded’, ‘Authorization’: “Basic b’MDBubDBranVSMWE5ckNIMHU4M0YxQTp6eDVFUkJLTWFtS1pjNWliRXZkajVuU1A3bjVjUTZ2SQ=='”}

These are the payload
{‘grant_type’: ‘authorization_code’, ‘code’: ‘bwEj9sgUtY62HPhq16kT8m-pnh4GyeE-g’, ‘redirct_uri’: ‘http://localhost:8000/zoom/oauth/callback’}

This is the response
[======response====]
{‘_content’: b’{“status”:false,“errorCode”:-1,“errorMessage”:“Illegal base64 character 27”,“result”:null}',

You are probably doing something wrong when encoding your client id and secret, you are encoding and decoding.

Take a look at these repos:

yup now getting {“reason”:“Invalid Grant”,“error”:“invalid_grant”} i checked the most common solution is giving the redirecturi in encoded format did that too

Hi @arsalan.9798
Were you able to troubleshoot this further?

No still stuck here , do you have any insight

Did you take a look at the OAuth sample app I shared with you? @arsalan.9798
Could you try authorizing the app and generating an access token using Postman?
Here is a very helpful guide on how to do so:

Yes I did and I am getting the same reply on postman as well

I will send you a private message @arsalan.9798