'Finish OAuth callback request.'

@callback
def get(self, request):

    from oauthlib.oauth2.rfc6749.errors import MismatchingStateError
    from oauthlib.oauth2.rfc6749.errors import MissingTokenError
    hass = request.app['hass']
    data = request.query
    response_message = 'Fitbit    has    been    successfully    authorized!\n                                You    can    close    this    window    now!'
    if (data.get('code') is not None):
        redirect_uri = '{}{}'.format(hass.config.api.base_url, FITBIT_AUTH_CALLBACK_PATH)
        try:
            self.oauth.fetch_access_token(data.get('code'), redirect_uri)
        except MissingTokenError as error:
            _LOGGER.error('Missing    token:    %s', error)
            response_message = 'Something    went    wrong    when\n                                                                attempting    authenticating    with    Fitbit.    The    error\n                                                                encountered    was    {}.    Please    try    again!'.format(error)
        except MismatchingStateError as error:
            _LOGGER.error('Mismatched    state,    CSRF    error:    %s', error)
            response_message = 'Something    went    wrong    when\n                                                                attempting    authenticating    with    Fitbit.    The    error\n                                                                encountered    was    {}.    Please    try    again!'.format(error)
    else:
        _LOGGER.error('Unknown    error    when    authing')
        response_message = 'Something    went    wrong    when\n                                                                attempting    authenticating    with    Fitbit.\n                                                                An    unknown    error    occurred.    Please    try    again!\n                                                                '
    html_response = '<html><head><title>Fitbit    Auth</title></head>\n                                <body><h1>{}</h1></body></html>'.format(response_message)
    config_contents = {ATTR_ACCESS_TOKEN: self.oauth.token['access_token'], ATTR_REFRESH_TOKEN: self.oauth.token['refresh_token'], ATTR_CLIENT_ID: self.oauth.client_id, ATTR_CLIENT_SECRET: self.oauth.client_secret}
    if (not config_from_file(hass.config.path(FITBIT_CONFIG_FILE), config_contents)):
        _LOGGER.error('Failed    to    save    config    file')
    hass.async_add_job(setup_platform, hass, self.config, self.add_devices)
    return html_response
