callback from a server

Asked

Viewed 110 times

0

People, I am involved in a project that requires the use of the Fitbit API. In my code, I redirect the user to the FITBIT site to authorize the use of the data. After authorizing, I need to grab the URL to get the Oauth code. How do I callback this redirect? It’s not exactly an ajax request because I don’t use either get or post or put, I just redirect the user.

  • You can show us what you’ve been trying?

  • 1

    Normally you set a URL to return (callback), this URL is one of your system where you can get the data returned by FITBIT.

1 answer

0

I don’t know if Fitbit uses Oauth2, but if so, it works like this:

Step 1: Vc redirects the user to the authentication page by passing the id and callback URL via GET method

Step 2: Fitbit calls the URL q vc passed a code via GET method

Step 3: You take the code q vc received and the secret and resubmit api for Fitbit via POST method.

At this point, Fitbit will return you a JSON with the access_token, which is what you will use for each API call.

IMPORTANT Your server must be accessible on the internet if you are using the server. Your private network or a virtual machine, you must configure the router/firewall to free external access to port 80 and 443.

Good luck

  • I get it, but the request doesn’t necessarily send the user to the link. How do I redirect? Just put a.Location window inside the request,on the. Done?

  • Or you can return http status 302 and add the "Location: www.fitbit.etc" field in the HTTP header, q would have the same effect. In short, the process is as described above, the way you redirect depends on the technology q vc is using. Fitbit uses Oauth2. https://dev.fitbit.com/docs/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.