Beispiel #1
0
    public async Task <ActionResult <object> > TraktDeviceAuthorization([FromRoute] string userId)
    {
        _logger.LogInformation("TraktDeviceAuthorization request received");

        // Create a user if we don't have one yet - TODO there should be an endpoint for this that creates a default user
        var traktUser = UserHelper.GetTraktUser(userId);

        if (traktUser == null)
        {
            Plugin.Instance.PluginConfiguration.AddUser(userId);
            traktUser = UserHelper.GetTraktUser(userId);
            Plugin.Instance.SaveConfiguration();
        }

        string userCode = await _traktApi.AuthorizeDevice(traktUser).ConfigureAwait(false);

        return(new
        {
            userCode
        });
    }