How to configure Callback URL for Oauth Services API integration

Dear all,
I am beginner with Python. I have few very basic scripts.
I am writing a script, that will get my measurement data from my weareable devices from Withings portal. I can easily check the measurements in the mobile application or web portal, but I would like to export the data into my own SQL database.
I see Withings have its own API endpoint. Based on vangorra/python_withings_api: Library for the Withings Health API (github.com), I need to have callback_uri value.
What is this value. ALso when I want to create “application” on Withings developer portal, it is askinm me fow callback_uri. It is connected with Oath2. What should be that value in my case?

This is the reference code, that I am trying to utilize:

from withings_api import WithingsAuth, WithingsApi, AuthScope

# Replace these with your client id and client secret
client_id = 'YOUR_CLIENT_ID'
client_secret = 'YOUR_CLIENT_SECRET'

# Set the callback URL and scopes
callback_uri = 'YOUR_CALLBACK_URL'
scopes = [AuthScope.USER_ACTIVITY, AuthScope.USER_METRICS, ...]

auth = WithingsAuth(client_id, client_secret, callback_uri, scopes)

# Get the authorization URL and have the user authorize your app
authorize_url = auth.get_authorize_url()
print("Go to this URL and authorize the app:", authorize_url)

# After authorization, get the authorization code from the callback URL
authorization_code = input("Enter the authorization code: ")

# Get the credentials
credentials = auth.get_credentials(authorization_code)

# Now you can use the WithingsApi to make requests
api = WithingsApi(credentials)

# Example: Fetching user activities
activities = api.measure_get_meas()
print(activities)

From above code, I don’t know what I should enter as callback_uri. Application description on the side of Withings, is also asking me for the same value.

Hey, there a call back URL could be any URL you specify that a user should be redirected to, in our case, a user has entered the authorization code where should he be redirected to incase of sucess or failure… from Django Oauth the callback URL is specified when your configuring Oauth for users to login using their Google accounts in a Django app… so I don’t know if Withings also has specified a call back URl.
something like this (http://127.0.0.1:8000/accounts/google/login/callback/)
PS: Ensure that the callback URL you use in your code should also be registered in your developer portal(i.e. Withings)

Hey Michael,
I don’t think Withings has their own callback URL. They are expecting end user to provide their own URL. I tried to select they one, you listed, but it is not accepted, since it is not reachable to their server.
Any idea?

No that was just an example in Django… use a developement URL to test … try this

http://localhost:3000/callback

and am also not sure if a script and web app could make a difference lol… coz in a web app you would have handled on how the callback url should work after getting the authorization code whether successful or not

aha so with this if the credentials are wrong it shouldn’t do anything like you can’t make requests

Hi,

Were you able to solve this issue?

I did apply my callback url, but I am unable to generate tokens. I am calling authorize which builds the callback url giving me code and the state.

After code gets generated by flask, I am getting tokens, but by Django, I am not getting tokens causing long time for loading and eventually throwing Token error.

Any assistance is appreciated.

Thanks