Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

OAuth 2.0 authentication in JavaScript examples?

Hi dev community,

I'm just getting started learning how to write web applications in general and I'd really appreciate some guidance. To start things off I'd like to write a simple program with the Fitbit API in HTML and JavaScript in which the user presses a button to go through the OAuth 2.0 authentication flow, and is then shown their username. Now that OAuth 1.0 is deprecated and about to be removed, I'm having a hard time finding example code using 2.0. Does anyone have any examples or this, or could at least point me in the right direction? I'm just trying to go with the simplest possible code. Thanks!

Best Answer
1 REPLY 1

Send the user through the OAuth 2.0 Implicit Grant flow. This ends with the user being redirected to your HTML page with an access_token in the URL fragment. You can use JavaScript to get the access_token value out of the fragment. Then, make XHRs to the URL of the resource you want to access with an "Authorization: Bearer TODO_put_your_access_token_here" header.

Best Answer
0 Votes