abjerner / Skybrud.Umbraco.Dashboard

Extended dashboard functionality and statistics package for Umbraco 7
MIT License
30 stars 4 forks source link

cant find Skybrud.Dashboard.config after installing nuget package #5

Open teeto opened 5 years ago

teeto commented 5 years ago

I would like to add a Google Analytics panel to an Umbraco Dashboard. I have installed Umbraco 7.12.4, then, i have installed the nuget package v1.0.0-beta4 Then i log into Umbraco and the Content section dashboard does not load. Looking into the log file, i see this error:

ERROR Skybrud.Umbraco.Dashboard.DashboardContext - Unable to load configuration file for the Dashboard: Could not find file 'C:\Webs_demos\Skybrud.Umbraco.Dashboard\Config\Skybrud.Dashboard.config'. System.IO.FileNotFoundException: Could not find file 'C:\Webs_demos\Skybrud.Umbraco.Dashboard\Config\Skybrud.Dashboard.config'. File name: 'C:\Webs_demos\Skybrud.Umbraco.Dashboard\Config\Skybrud.Dashboard.config' at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost) at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost) at System.IO.File.ReadAllText(String path) at Skybrud.Umbraco.Dashboard.Config.DashboardConfiguration.Load(String path) at Skybrud.Umbraco.Dashboard.DashboardContext..ctor()

teeto commented 5 years ago

It seems that after installing the nuget package this config file should be created, but it doesnt. I cant find any info about manually creating this config file.

abjerner commented 5 years ago

@teeto Sorry about that. This repository/package mostly served as a proof of concept for adding dashboards from C#. I haven't really updated the code much since then.

The integration with Analytics was just an example of what could be added, and ideally that part should be moved to a separate project. I even removed it from the code roughly a year ago, but never got around to create a new project for the Analytics integration.

Anyways - the most recent version of this package on NuGet still has the Analytics integration. The Skybrud.Dashboard.config file could look something like this:

{
    "analytics": {
        "clients": [
            {
                "id": "a unique identifier - could be a GUID",
                "clientId": "Client ID of your Google app",
                "clientSecret": "Client secret of your Google app",
                "users": [
                    {
                        "id": "The ID of a Google account",
                        "email": "The email of a Google account",
                        "name": "The name of a Google account",
                        "refreshToken": "The refresh token of a Google account"
                    }
                ]
            }
        ]
    }
}

The idea is that you add one or more Google apps/clients, which again has one or more users. The refreshToken of each user is - along with the clientId and clientSecret of the app - used to to obtain new access tokens, which are then used to access the Analytics API.

This package does however not help you with that. You could set up an authentication page, and obtain a refresh token that way.

While the examples mostly explains how to obtain an access token, you can read more about authenticating with Google here:

https://social.skybrud.dk/google/authentication/

When authenticating, you should make sure to request the AnalyticsScope.Readonly scope:

https://social.skybrud.dk/google/analytics/scope/

Hope that helps ;)

teeto commented 5 years ago

Thanks @abjerner !

So i should create this config file and provide a method to auth the user in Google and store the credentials in this config file? And to do so, i could use Skybrud.Social? but in your link you say it is deprecated, so you dont recommend use it any more?

I would like to use Skybrud.Social.Umbraco.v1.0.7 package to try it out.

teeto commented 5 years ago

I have installed Skybrud.Social.Umbraco.v1.0.7 and used to get Google data without problem, following this thread: https://our.umbraco.com/packages/website-utilities/skybrudsocial-for-umbraco-7/general-discussion/91040-getting-started

I have created the Skybrud.Dashboard.config file with that info filled and still i get the error:

Request error: The URL returned a 404 (not found): /umbraco/backoffice/SkybrudDashboard/Dashboard/GetRemoteDashboardContent

But now there is no info in the Umbraco log

abjerner commented 5 years ago

@teeto The documentation is actually right that the package Skybrud.Social is deprecated - this is in favor of individual packages - eg. Skybrud.Social.Google for the integration with the supported Google APIs.

The difference between the packages may be a little confusing at the moment - partially because I haven't had the time to fully catch up. Therefore most of the individual packages are still in beta (they are fine to use in production, but there may come breaking changes in the future - hence the beta label).

Also, as a result of the above, both Skybrud.Umbraco.Dashboard and Skybrud.Social.Umbraco, are actually still using the older Skybrud.Social.

The 404 error may be due to some changes in recent versions of Umbraco. As explained in the readme here on GitHub, this package works by replacing Umbraco's dashboard API controller with a custom one. So apparently Umbraco has added a new method in their controller, which is then missing in mine. I don't have a fix for this issue at the moment, but I will investigate further ;)

teeto commented 5 years ago

OK, thank you!! the Skybrud.Social.Umbraco works great. Any idea pointing me in the direction to make an Analytics panel once i have the credentials?