Giter Club home page Giter Club logo

sdk-oauth's Introduction

sdk-oauth

A sample application which uses the Settings API OAuth component, and the Fitbit Web API to query sleep data.

Usage

  1. You must first register a Web Application on dev.fitbit.com to get an OAuth ID and secret. Configure the application as:
  1. Enter your OAuth 2.0 Client ID and Client Secret into settings/index.jsx

  2. After installing the project from Fitbit Studio, you need to login to the Fitbit Web API using the settings page within the Fitbit mobile application.

    Fitbit mobile app > Ionic > Developer menu > your app > Settings

Read more in the Reference documentation.

sdk-oauth's People

Contributors

orviwan avatar tylerleonhardt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk-oauth's Issues

error when trying to use the link to create a session

Error when using the link to create a session in case this test link: https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=22942C&redirect_uri=https%3A%2F%2Fexample.com%2Ffitbit_auth&scope=activity% 20nutrition% 20heartrate% 20location% 20nutrition% 20profile% 20settings% 20sleep% 20social% 20weight

This error happened when using the library to direct this link, the library is: oauth2-popup-flow version: ^ 1.1.0.

Doing the following process:

a file is created that will be imported in the future to perform the function in this case the file is called: auth.js with the following description:

import { OAuth2PopupFlow } from 'oauth2-popup-flow';

export default new OAuth2PopupFlow({
  authorizationUri: 'https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=22942C&redirect_uri=https%3A%2F%2Fexample.com%2Ffitbit_auth&scope=activity%20nutrition%20heartrate%20location%20nutrition%20profile%20settings%20sleep%20social%20weight',
  clientId: '50c71b28db301de7ee0c57fdce9d433f',
  redirectUri: 'http://localhost:8080/redirect',
  scope: 'openid profile',
  responseType: 'id_token',
  accessTokenResponseKey: 'id_token',
  additionalAuthorizationParameters: {
    nonce: Math.random().toString(),
  },
});

After that we have to import it into the App.js file that works as follows:

import React from 'react';
import auth from './auth';

function App() {
  async function test() {
    await auth.tryLoginPopup();
  }

  return (
    <div>
      <button type="button" onClick={() => {
        test();
      }}>test</button>
    </div>
  );
}

export default App;

Result after clicking the button is the image below:

image

After that I could not perform any other step, with this we have this error.

todayDate may need zero-padding

The month and date in todayDate need to be zero-padded to conform with the API spec. The sleep API doesn't seem to care, but the heartrate endpoint can return a different sort of object if it gets a malformed date.

Cannot refresh access token

Hello,

I have currently some problems with the OAuth button in the settings. I get an access token from Google, but not a refresh token to get a new access token. To get that refresh token I have to pass another parameter to the authorization URL according to this StackOverflow post.

Here is my OAuth button for now:

<Oauth
    settingsKey="oauth"
    title="Google Login"
    label="Google"
    status="Login"
    authorizeUrl="https://accounts.google.com/o/oauth2/v2/auth"
    clientId="xxxxxxx"
    clientSecret="xxxxxxxx"
    scope="https://www.googleapis.com/auth/drive.readonly"
    onReturn={async (data) => {
        props.settingsStorage.setItem('oauth_code', data.code);
     }}
 />

Is there a workaround or something in development to adding additionally parameters to the authorization process?

Thank you in advance.

Friends API is returning empty

Thank you for this example code, it was really helpful in learning how to use the oauth.

I modified the code and added the 'social' scope to the oauth. When I try to fetch the friends list, it is returning empty. I'm logged in as my own profile in the simulator, and I do have a few friends. Is there something I am missing?

Example of refreshing the access token

This example is a good start, but it's missing a few, IMO, crucial things.

  1. The access token that comes from the OAuth request in the settings page eventually expires, forcing the user to have to re-auth in the settings. This is not ideal. I know there's a concept of a refresh token and it'd be awesome to get an example of that!

  2. (lower pri) an example POST request to the fitbit's API. I learned after a whole lot of digging that the POST body data is passed in as query params instead of in a JSON body. That wasn't really exactly clear in the docs and this didn't have an example of POSTing so I was kind of left in the dark until I found the swagger spec.

I'm trying to submit an app for the challenge deadline on Friday and would love to have #1 in my app!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.