Connecting to Google OAuth 2.0

Hi, I am new to Tidbyt. I am trying to authenticate using Google OAuth 2.0. I believe I have configured everything correctly, but I am getting the following error every time when login:

calling schema handler oauth_handler: Traceback (most recent call last): broadcast.star:39:20: in oauth_handler Error in post: expected param value for key ‘“client_secret”’ to be a string. got: ‘NoneType’

I am using the client id and client secret from Google Console

This is what I have following the example code:

res = http.post(
        url = "https://accounts.google.com/o/oauth2/v2/auth",
        headers = {
            "Accept": "application/json",
        },
        form_body = dict(
            params,
            client_secret = OAUTH2_CLIENT_SECRET,
        ),
        form_encoding = "application/x-www-form-urlencoded",
)

Thanks!

I figured out after some researching. Here is how I got it to work if anyone is looking.


params = json.decode(params)

res = http.post(
        url = "https://oauth2.googleapis.com/token",
        headers = { "Content-type": "application/x-www-form-urlencoded" },
        body = "code=" + params["code"] + "&client_id=" + params["client_id"] + "&redirect_uri=" + params["redirect_uri"] + "&grant_type=" + params["grant_type"] + "&client_secret=" + OAUTH2_CLIENT_SECRET,
)
1 Like