#NEWLINE# @ cherrypy . expose #NEWLINE# def index( self , state , code = None , error = None ) : #NEWLINE# #INDENT# '\n        Receive a Fitbit response containing a verification code. Use the code\n        to fetch the access_token.\n        ' #NEWLINE# error = None #NEWLINE# if code : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . oauth . fetch_access_token ( code , self . redirect_uri ) #NEWLINE# #UNINDENT# except MissingTokenError : #NEWLINE# #INDENT# error = self . _fmt_failure ( 'Missing access token parameter.</br>Please check that you are using the correct client_secret' ) #NEWLINE# #UNINDENT# except MismatchingStateError : #NEWLINE# #INDENT# error = self . _fmt_failure ( 'CSRF Warning! Mismatching state' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# error = self . _fmt_failure ( 'Unknown error while authenticating' ) #NEWLINE# #UNINDENT# self . _shutdown_cherrypy ( ) #NEWLINE# return ( error if error else self . success_html )