質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
OAuth 2.0

OAuth 2.0(Open Authorization 2.0)は、APIを通して保護されたリソース(サードパーティのアプリケーション)へアクセスする為のオープンプロトコルです。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

4205閲覧

fitbitAPIからのデータ取得

another2118

総合スコア8

OAuth 2.0

OAuth 2.0(Open Authorization 2.0)は、APIを通して保護されたリソース(サードパーティのアプリケーション)へアクセスする為のオープンプロトコルです。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2016/06/29 04:46

編集2016/06/29 06:49

###前提・実現したいこと
fitbit charge hrから1分単位の心拍数や歩行データを取得できると聞きmacbookにpythonを入れてターミナルで動かしていますがどうにもうまくいきません

↓この方のブログを参考にしています。
http://blog.mr-but-dr.xyz/programming/fitbit-python-heartrate-howto/
###発生している問題・エラーメッセージ

pc☆☆☆☆☆:python-fitbit-master ☆☆☆☆☆$ python3 gather_keys_oauth2.py "OAuth 2.0 ☆☆☆☆☆" "☆☆☆☆☆☆☆☆☆" とターミナルに入力すると [23/Jun/2016:16:32:03] ENGINE Listening for SIGTERM. [23/Jun/2016:16:32:03] ENGINE Listening for SIGHUP. [23/Jun/2016:16:32:03] ENGINE Listening for SIGUSR1. [23/Jun/2016:16:32:03] ENGINE Bus STARTING CherryPy Checker: The Application mounted at '' has an empty config. [23/Jun/2016:16:32:03] ENGINE Started monitor thread 'Autoreloader'. [23/Jun/2016:16:32:03] ENGINE Started monitor thread '_TimeoutMonitor'. [23/Jun/2016:16:32:03] ENGINE Serving on http://127.0.0.1:8080 [23/Jun/2016:16:32:03] ENGINE Bus STARTED ^[[A^C[23/Jun/2016:16:54:58] ENGINE Keyboard Interrupt: shutting down bus [23/Jun/2016:16:54:58] ENGINE Bus STOPPING [23/Jun/2016:16:54:58] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 8080)) shut down [23/Jun/2016:16:54:58] ENGINE Stopped thread '_TimeoutMonitor'. [23/Jun/2016:16:54:58] ENGINE Stopped thread 'Autoreloader'. [23/Jun/2016:16:54:58] ENGINE Bus STOPPED [23/Jun/2016:16:54:58] ENGINE Bus EXITING [23/Jun/2016:16:54:58] ENGINE Bus EXITED [23/Jun/2016:16:54:58] ENGINE Waiting for child threads to terminate... FULL RESULTS = {'access_token': None, 'refresh_token': None} ACCESS_TOKEN = None REFRESH_TOKEN = None と表示されブラウザが開きますが 「接続しようとしているアプリは Fitbit に有効なデータを提供しませんでした。この問題を報告してください。 Developer information: unauthorized_client - Invalid client_id 」 と表示されうまくいきません 途中で文字の入力ができるようになりますが何を入力したらよいか分からずcontrol+cで終了させてしまっています。 ここからどうすればトークンの生成などができるのかわからないのでどなたかお力添えを宜しくお願い致します。

###該当のソースコード

gather_keys_oauth2.py の中身は https://github.com/orcasgit/python-fitbit にあるものとほぼ同じです #!/usr/bin/env python import cherrypy import os import sys import threading import traceback import webbrowser from base64 import b64encode from fitbit.api import FitbitOauth2Client from oauthlib.oauth2.rfc6749.errors import MismatchingStateError, MissingTokenError from requests_oauthlib import OAuth2Session class OAuth2Server: def __init__(self, client_id, client_secret, redirect_uri='http://127.0.0.1:8000/'): """ Initialize the FitbitOauth2Client """ self.redirect_uri = redirect_uri self.success_html = """ <h1>You are now authorized to access the Fitbit API!</h1> <br/><h3>You can close this window</h3>""" self.failure_html = """ <h1>ERROR: %s</h1><br/><h3>You can close this window</h3>%s""" self.oauth = FitbitOauth2Client(client_id, client_secret) def browser_authorize(self): """ Open a browser to the authorization url and spool up a CherryPy server to accept the response """ url, _ = self.oauth.authorize_token_url(redirect_uri=self.redirect_uri) # Open the web browser in a new thread for command-line browser support threading.Timer(1, webbrowser.open, args=(url,)).start() cherrypy.quickstart(self) @cherrypy.expose def index(self, state, code=None, error=None): """ Receive a Fitbit response containing a verification code. Use the code to fetch the access_token. """ error = None if code: try: self.oauth.fetch_access_token(code, self.redirect_uri) except MissingTokenError: error = self._fmt_failure( 'Missing access token parameter.</br>Please check that ' 'you are using the correct client_secret') except MismatchingStateError: error = self._fmt_failure('CSRF Warning! Mismatching state') else: error = self._fmt_failure('Unknown error while authenticating') # Use a thread to shutdown cherrypy so we can return HTML first self._shutdown_cherrypy() return error if error else self.success_html def _fmt_failure(self, message): tb = traceback.format_tb(sys.exc_info()[2]) tb_html = '<pre>%s</pre>' % ('\n'.join(tb)) if tb else '' return self.failure_html % (message, tb_html) def _shutdown_cherrypy(self): """ Shutdown cherrypy in one second, if it's running """ if cherrypy.engine.state == cherrypy.engine.states.STARTED: threading.Timer(1, cherrypy.engine.exit).start() if __name__ == '__main__': if not (len(sys.argv) == 3): print("Arguments: client_id and client_secret") sys.exit(1) server = OAuth2Server(*sys.argv[1:]) server.browser_authorize() print('FULL RESULTS = %s' % server.oauth.token) print('ACCESS_TOKEN = %s' % server.oauth.token['access_token']) print('REFRESH_TOKEN = %s' % server.oauth.token['refresh_token'])

###試したこと
なにかしらの入力を
[23/Jun/2016:16:32:03] ENGINE Bus STARTED
の後に迫られますがここの入力で思い当たる文字列を入力しましたが何も変化がなくcontrol+cで終了させてしまいました

###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

自分で入力したポート番号と登録したポート番号が間違っていただけのようでした

投稿2016/07/26 09:27

another2118

総合スコア8

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問