├── src ├── WebEssentials-Settings.json ├── build │ ├── Newtonsoft.Json.dll │ ├── Skybrud.Essentials.dll │ └── Skybrud.BuildTools.Tasks.exe ├── assemblies │ ├── Skybrud.Social.Mailchimp.dll │ └── Skybrud.Social.Mailchimp.xml ├── Skybrud.Social.Umbraco │ ├── compilerconfig.json │ ├── Constants │ │ └── SocialConstants.cs │ ├── Models │ │ ├── Facebook │ │ │ ├── FacebookOAuthState.cs │ │ │ └── FacebookOAuthData.cs │ │ ├── Mailchimp │ │ │ ├── MailchimpOAuthState.cs │ │ │ └── MailchimpOAuthData.cs │ │ ├── Google │ │ │ ├── GoogleOAuthState.cs │ │ │ ├── GoogleScopeGroup.cs │ │ │ └── GoogleOAuthData.cs │ │ └── Mvc │ │ │ └── PageModel.cs │ ├── Components │ │ ├── SocialComposer.cs │ │ └── SocialComponent.cs │ ├── App_Plugins │ │ └── Skybrud.Social │ │ │ ├── Views │ │ │ ├── AuthenticateError.cshtml │ │ │ ├── Facebook │ │ │ │ ├── AuthenticateSuccess.cshtml │ │ │ │ └── OAuth.html │ │ │ ├── Google │ │ │ │ ├── AuthenticateSuccess.cshtml │ │ │ │ ├── OAuth.html │ │ │ │ ├── OAuthInfo.html │ │ │ │ └── OAuthScopes.html │ │ │ ├── Mailchimp │ │ │ │ ├── AuthenticateSuccess.cshtml │ │ │ │ └── OAuth.html │ │ │ └── Layout.cshtml │ │ │ ├── Styles │ │ │ └── Default.less │ │ │ ├── Scripts │ │ │ ├── Google │ │ │ │ ├── OAuth.js │ │ │ │ └── OAuthScopes.js │ │ │ ├── Facebook │ │ │ │ └── OAuth.js │ │ │ └── Mailchimp │ │ │ │ └── OAuth.js │ │ │ └── package.manifest │ ├── Controllers │ │ ├── Api │ │ │ └── GoogleController.cs │ │ └── Surface │ │ │ ├── Hest.cs │ │ │ ├── FacebookOAuthController.cs │ │ │ ├── MailchimpOAuthController.cs │ │ │ └── GoogleOAuthController.cs │ ├── Json │ │ └── Converters │ │ │ └── SocialJsonConverter.cs │ ├── compilerconfig.json.defaults │ ├── DataTypes │ │ └── MailchimpOAuthDataPropertyValueConverter.cs │ └── Skybrud.Social.Umbraco.csproj └── Skybrud.Social.Umbraco.sln ├── releases ├── github │ ├── Skybrud.Social.Umbraco.v1.0.0.zip │ ├── Skybrud.Social.Umbraco.v1.0.1.zip │ ├── Skybrud.Social.Umbraco.v1.0.2.zip │ ├── Skybrud.Social.Umbraco.v1.0.3.zip │ ├── Skybrud.Social.Umbraco.v1.0.4.zip │ ├── Skybrud.Social.Umbraco.v1.0.5.zip │ ├── Skybrud.Social.Umbraco.v1.0.6.zip │ ├── Skybrud.Social.Umbraco.v1.0.7.zip │ └── Skybrud.Social.Umbraco.v2.0.0-alpha001.zip ├── nuget │ ├── Skybrud.Social.Umbraco.1.0.0.nupkg │ ├── Skybrud.Social.Umbraco.1.0.1.nupkg │ ├── Skybrud.Social.Umbraco.1.0.2.nupkg │ ├── Skybrud.Social.Umbraco.1.0.3.nupkg │ ├── Skybrud.Social.Umbraco.1.0.4.nupkg │ ├── Skybrud.Social.Umbraco.1.0.5.nupkg │ ├── Skybrud.Social.Umbraco.1.0.6.nupkg │ ├── Skybrud.Social.Umbraco.1.0.7.nupkg │ └── Skybrud.Social.Umbraco.2.0.0-alpha001.nupkg └── umbraco │ ├── Skybrud.Social.Umbraco.v1.0.0.zip │ ├── Skybrud.Social.Umbraco.v1.0.1.zip │ ├── Skybrud.Social.Umbraco.v1.0.2.zip │ ├── Skybrud.Social.Umbraco.v1.0.3.zip │ ├── Skybrud.Social.Umbraco.v1.0.4.zip │ ├── Skybrud.Social.Umbraco.v1.0.5.zip │ ├── Skybrud.Social.Umbraco.v1.0.6.zip │ └── Skybrud.Social.Umbraco.v1.0.7.zip ├── .gitignore ├── release.bat ├── LICENSE.md ├── skybrud.build.json └── README.md /src/WebEssentials-Settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Less": { 3 | "GenerateSourceMaps": false 4 | } 5 | } -------------------------------------------------------------------------------- /src/build/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/src/build/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /src/build/Skybrud.Essentials.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/src/build/Skybrud.Essentials.dll -------------------------------------------------------------------------------- /src/build/Skybrud.BuildTools.Tasks.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/src/build/Skybrud.BuildTools.Tasks.exe -------------------------------------------------------------------------------- /src/assemblies/Skybrud.Social.Mailchimp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/src/assemblies/Skybrud.Social.Mailchimp.dll -------------------------------------------------------------------------------- /releases/github/Skybrud.Social.Umbraco.v1.0.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/github/Skybrud.Social.Umbraco.v1.0.0.zip -------------------------------------------------------------------------------- /releases/github/Skybrud.Social.Umbraco.v1.0.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/github/Skybrud.Social.Umbraco.v1.0.1.zip -------------------------------------------------------------------------------- /releases/github/Skybrud.Social.Umbraco.v1.0.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/github/Skybrud.Social.Umbraco.v1.0.2.zip -------------------------------------------------------------------------------- /releases/github/Skybrud.Social.Umbraco.v1.0.3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/github/Skybrud.Social.Umbraco.v1.0.3.zip -------------------------------------------------------------------------------- /releases/github/Skybrud.Social.Umbraco.v1.0.4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/github/Skybrud.Social.Umbraco.v1.0.4.zip -------------------------------------------------------------------------------- /releases/github/Skybrud.Social.Umbraco.v1.0.5.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/github/Skybrud.Social.Umbraco.v1.0.5.zip -------------------------------------------------------------------------------- /releases/github/Skybrud.Social.Umbraco.v1.0.6.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/github/Skybrud.Social.Umbraco.v1.0.6.zip -------------------------------------------------------------------------------- /releases/github/Skybrud.Social.Umbraco.v1.0.7.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/github/Skybrud.Social.Umbraco.v1.0.7.zip -------------------------------------------------------------------------------- /releases/nuget/Skybrud.Social.Umbraco.1.0.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/nuget/Skybrud.Social.Umbraco.1.0.0.nupkg -------------------------------------------------------------------------------- /releases/nuget/Skybrud.Social.Umbraco.1.0.1.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/nuget/Skybrud.Social.Umbraco.1.0.1.nupkg -------------------------------------------------------------------------------- /releases/nuget/Skybrud.Social.Umbraco.1.0.2.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/nuget/Skybrud.Social.Umbraco.1.0.2.nupkg -------------------------------------------------------------------------------- /releases/nuget/Skybrud.Social.Umbraco.1.0.3.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/nuget/Skybrud.Social.Umbraco.1.0.3.nupkg -------------------------------------------------------------------------------- /releases/nuget/Skybrud.Social.Umbraco.1.0.4.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/nuget/Skybrud.Social.Umbraco.1.0.4.nupkg -------------------------------------------------------------------------------- /releases/nuget/Skybrud.Social.Umbraco.1.0.5.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/nuget/Skybrud.Social.Umbraco.1.0.5.nupkg -------------------------------------------------------------------------------- /releases/nuget/Skybrud.Social.Umbraco.1.0.6.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/nuget/Skybrud.Social.Umbraco.1.0.6.nupkg -------------------------------------------------------------------------------- /releases/nuget/Skybrud.Social.Umbraco.1.0.7.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/nuget/Skybrud.Social.Umbraco.1.0.7.nupkg -------------------------------------------------------------------------------- /releases/umbraco/Skybrud.Social.Umbraco.v1.0.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/umbraco/Skybrud.Social.Umbraco.v1.0.0.zip -------------------------------------------------------------------------------- /releases/umbraco/Skybrud.Social.Umbraco.v1.0.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/umbraco/Skybrud.Social.Umbraco.v1.0.1.zip -------------------------------------------------------------------------------- /releases/umbraco/Skybrud.Social.Umbraco.v1.0.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/umbraco/Skybrud.Social.Umbraco.v1.0.2.zip -------------------------------------------------------------------------------- /releases/umbraco/Skybrud.Social.Umbraco.v1.0.3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/umbraco/Skybrud.Social.Umbraco.v1.0.3.zip -------------------------------------------------------------------------------- /releases/umbraco/Skybrud.Social.Umbraco.v1.0.4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/umbraco/Skybrud.Social.Umbraco.v1.0.4.zip -------------------------------------------------------------------------------- /releases/umbraco/Skybrud.Social.Umbraco.v1.0.5.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/umbraco/Skybrud.Social.Umbraco.v1.0.5.zip -------------------------------------------------------------------------------- /releases/umbraco/Skybrud.Social.Umbraco.v1.0.6.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/umbraco/Skybrud.Social.Umbraco.v1.0.6.zip -------------------------------------------------------------------------------- /releases/umbraco/Skybrud.Social.Umbraco.v1.0.7.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/umbraco/Skybrud.Social.Umbraco.v1.0.7.zip -------------------------------------------------------------------------------- /releases/github/Skybrud.Social.Umbraco.v2.0.0-alpha001.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/github/Skybrud.Social.Umbraco.v2.0.0-alpha001.zip -------------------------------------------------------------------------------- /releases/nuget/Skybrud.Social.Umbraco.2.0.0-alpha001.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abjerner/Skybrud.Social.Umbraco/HEAD/releases/nuget/Skybrud.Social.Umbraco.2.0.0-alpha001.nupkg -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/compilerconfig.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "outputFile": "App_Plugins/Skybrud.Social/Styles/Default.css", 4 | "inputFile": "App_Plugins/Skybrud.Social/Styles/Default.less" 5 | } 6 | ] -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | package/files/ 2 | src/packages/ 3 | src/Skybrud.Social.Umbraco/bin/ 4 | src/Skybrud.Social.Umbraco/obj/ 5 | 6 | NuGetBackup 7 | *.user 8 | *.suo 9 | files/ 10 | *.css 11 | *.map 12 | node_modules/ 13 | src/.vs/ 14 | -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Constants/SocialConstants.cs: -------------------------------------------------------------------------------- 1 | namespace Skybrud.Social.Umbraco.Constants { 2 | 3 | public static class SocialConstants { 4 | 5 | public const string PluginController = "SkybrudSocial"; 6 | 7 | } 8 | 9 | } -------------------------------------------------------------------------------- /release.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd src/Skybrud.Social.Umbraco 3 | "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\msbuild.exe" /t:rebuild /t:pack /p:Configuration=Release /p:PackageOutputPath=../../releases/nuget 4 | cd ../../ -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Models/Facebook/FacebookOAuthState.cs: -------------------------------------------------------------------------------- 1 | namespace Skybrud.Social.Umbraco.Models.Facebook { 2 | 3 | public class FacebookOAuthState { 4 | 5 | public string Callback { get; set; } 6 | 7 | public string ContentTypeAlias { get; set; } 8 | 9 | public string PropertyAlias { get; set; } 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Models/Mailchimp/MailchimpOAuthState.cs: -------------------------------------------------------------------------------- 1 | namespace Skybrud.Social.Umbraco.Models.Mailchimp { 2 | 3 | public class MailchimpOAuthState { 4 | 5 | public string Callback { get; set; } 6 | 7 | public string ContentTypeAlias { get; set; } 8 | 9 | public string PropertyAlias { get; set; } 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Models/Google/GoogleOAuthState.cs: -------------------------------------------------------------------------------- 1 | //namespace Skybrud.Social.Umbraco.Models.Google { 2 | 3 | // public class GoogleOAuthState { 4 | 5 | // public string Callback { get; set; } 6 | 7 | // public string ContentTypeAlias { get; set; } 8 | 9 | // public string PropertyAlias { get; set; } 10 | 11 | // } 12 | 13 | 14 | //} -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Components/SocialComposer.cs: -------------------------------------------------------------------------------- 1 | using Umbraco.Core; 2 | using Umbraco.Core.Composing; 3 | 4 | namespace Skybrud.Social.Umbraco.Components { 5 | 6 | [RuntimeLevel(MinLevel = RuntimeLevel.Run)] 7 | public class SocialComposer : IUserComposer { 8 | 9 | public void Compose(Composition composition) { 10 | composition.Components().Append(); 11 | } 12 | 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Views/AuthenticateError.cshtml: -------------------------------------------------------------------------------- 1 | @inherits System.Web.Mvc.WebViewPage 2 | 3 | @{ 4 | Layout = "Layout.cshtml"; 5 | } 6 | 7 |
8 | @Model.Title 9 |
10 | @Model.Message 11 |
12 | Close window 13 |
-------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Controllers/Api/GoogleController.cs: -------------------------------------------------------------------------------- 1 | //using Skybrud.Social.Google.Scopes; 2 | //using Skybrud.Social.Umbraco.Constants; 3 | //using Umbraco.Web.Mvc; 4 | //using Umbraco.Web.WebApi; 5 | 6 | //namespace Skybrud.Social.Umbraco.Controllers.Api { 7 | 8 | // [PluginController(SocialConstants.PluginController)] 9 | // public class GoogleController : UmbracoAuthorizedApiController { 10 | 11 | // public object GetScopes() { 12 | // return Json(GoogleScopeGroup.GetAll()); 13 | // } 14 | 15 | // } 16 | 17 | //} -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Styles/Default.less: -------------------------------------------------------------------------------- 1 | .SkybrudSocial { 2 | 3 | &.Google.OAuthScopes { 4 | 5 | label { 6 | display: flex; 7 | button { 8 | margin-right: 20px; 9 | } 10 | } 11 | 12 | } 13 | 14 | } 15 | 16 | 17 | @info: #2e8aea; 18 | 19 | .notice { 20 | background: @info; 21 | color: white; 22 | padding: 10px; 23 | } 24 | 25 | .notice strong { 26 | color: white; 27 | } 28 | 29 | .notice.icon > div { 30 | padding-left: 25px; 31 | } 32 | 33 | .notice i.icon { 34 | float: left; 35 | font-size: 16px; 36 | } -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Views/Facebook/AuthenticateSuccess.cshtml: -------------------------------------------------------------------------------- 1 | @using Newtonsoft.Json.Linq 2 | @inherits System.Web.Mvc.WebViewPage 3 | 4 | @{ 5 | Layout = "../Layout.cshtml"; 6 | } 7 | 8 |
9 |

Hi @Model.User.Name

10 |

Please wait while you're being redirected...

11 | Close window 12 |
13 | 14 | -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Views/Google/AuthenticateSuccess.cshtml: -------------------------------------------------------------------------------- 1 | @using Newtonsoft.Json.Linq 2 | @inherits System.Web.Mvc.WebViewPage 3 | 4 | @{ 5 | Layout = "../Layout.cshtml"; 6 | } 7 | 8 |
9 |

Hi @Model.CallbackData.User.Name

10 |

Please wait while you're being redirected...

11 | Close window 12 |
13 | 14 | -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Views/Mailchimp/AuthenticateSuccess.cshtml: -------------------------------------------------------------------------------- 1 | @using Newtonsoft.Json.Linq 2 | @inherits System.Web.Mvc.WebViewPage 3 | 4 | @{ 5 | Layout = "../Layout.cshtml"; 6 | } 7 | 8 |
9 |

Hi @Model.Meta.Login.LoginName

10 |

Please wait while you're being redirected...

11 | Close window 12 |
13 | 14 | -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Components/SocialComponent.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Skybrud.Social.Umbraco.Constants; 3 | using Umbraco.Core.Composing; 4 | using Umbraco.Web.JavaScript; 5 | 6 | namespace Skybrud.Social.Umbraco.Components { 7 | public class SocialComponent : IComponent { 8 | 9 | public void Initialize() { 10 | ServerVariablesParser.Parsing += ServerVariablesParserOnParsing; 11 | } 12 | 13 | public void Terminate() { } 14 | 15 | private void ServerVariablesParserOnParsing(object sender, Dictionary dictionary) { 16 | dictionary["skybrudSocial"] = new Dictionary { 17 | { "webApiBaseUrl", $"/umbraco/backoffice/{SocialConstants.PluginController}/" }, 18 | { "surfaceBaseUrl", $"/umbraco/{SocialConstants.PluginController}/" } 19 | }; 20 | } 21 | 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Views/Google/OAuth.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 |
6 |
7 | 8 |
9 |
10 |
11 | {{model.value.user.name}} (ID: {{model.value.user.id}}) 12 |
13 | 14 |
15 |
16 |
17 |
-------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Views/Google/OAuthInfo.html: -------------------------------------------------------------------------------- 1 |
2 | Google uses OAuth 2.0 for authentication and communication. In order for 3 | users to authenticate with the Google API, you must specify the ID, secret and redirect URI 4 | of your Google app. You can create a new app at the following URL: 5 | https://console.developers.google.com/project
6 |
7 |
8 | 9 |
10 | When a user authenticates with the Google API, a refresh token is 11 | saved along with information about the user. The refresh token can be used to obtain an 12 | access token, which again can be used to make calls to the Google API. Refresh tokens will 13 | not expire unless the user deauthorizes the app. Access tokens will only have a lifetime of 14 | about an hour.
15 |
16 |
17 |
-------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Views/Mailchimp/OAuth.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 |
6 |
7 | 8 |
9 |
10 |
11 | {{model.value.meta.login.login_name}} (ID: {{model.value.meta.login.login_id}}) 12 |
13 | 14 |
15 |
16 |
17 |
-------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Controllers/Surface/Hest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | using Skybrud.Essentials.Json; 4 | 5 | namespace Skybrud.Social.Umbraco.Controllers.Surface { 6 | 7 | public class JsonObjectBaseConverter : JsonConverter { 8 | 9 | public override bool CanRead => false; 10 | 11 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { 12 | 13 | JsonObjectBase obj = value as JsonObjectBase; 14 | 15 | if (obj?.JObject == null) { 16 | writer.WriteNull(); 17 | return; 18 | } 19 | 20 | obj.JObject.WriteTo(writer); 21 | 22 | } 23 | 24 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { 25 | throw new NotImplementedException(); 26 | } 27 | 28 | public override bool CanConvert(Type objectType) { 29 | return true; 30 | } 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 [Anders Bjerner](https://twitter.com/abjerner) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Scripts/Google/OAuth.js: -------------------------------------------------------------------------------- 1 | angular.module("umbraco").controller("Skybrud.Social.Google.OAuth.Controller", function ($scope, $element, editorState) { 2 | 3 | // Get the server variables for "Skybrud.Social" 4 | var variables = window.Umbraco.Sys.ServerVariables.skybrudSocial; 5 | 6 | $scope.editorState = editorState.current; 7 | 8 | // Define an alias for the editor (eg. used for callbacks) 9 | var alias = $scope.alias = ("skybrudsocial_" + Math.random()).replace(".", ""); 10 | 11 | $scope.authenticate = function () { 12 | var url = variables.surfaceBaseUrl + "GoogleOAuth/Authenticate?callback=" + alias + "&contentTypeAlias=" + editorState.current.contentTypeAlias + "&propertyAlias=" + $scope.model.alias; 13 | window.open(url, "Authenticate with Google", "scrollbars=no,resizable=yes,menubar=no,width=800,height=700"); 14 | }; 15 | 16 | $scope.reset = function () { 17 | $scope.model.value = null; 18 | }; 19 | 20 | window[alias] = function (data) { 21 | $scope.$apply(function () { 22 | $scope.model.value = data; 23 | }); 24 | } 25 | 26 | }); -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Json/Converters/SocialJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Newtonsoft.Json; 4 | //using Skybrud.Social.Google.Scopes; 5 | 6 | namespace Skybrud.Social.Umbraco.Json.Converters { 7 | 8 | public class SocialJsonConverter : JsonConverter { 9 | 10 | public override bool CanRead => false; 11 | 12 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { 13 | 14 | switch (value) { 15 | 16 | //case GoogleScope[] array: 17 | // writer.WriteValue(String.Join(" ", from scope in array select scope.Alias)); 18 | // return; 19 | 20 | default: 21 | writer.WriteNull(); 22 | return; 23 | 24 | } 25 | 26 | } 27 | 28 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { 29 | throw new NotImplementedException(); 30 | } 31 | 32 | public override bool CanConvert(Type objectType) { 33 | return true; 34 | } 35 | 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Scripts/Facebook/OAuth.js: -------------------------------------------------------------------------------- 1 | angular.module("umbraco").controller("Skybrud.Social.Facebook.OAuth.Controller", function ($scope, $element, editorState) { 2 | 3 | // Get the server variables for "Skybrud.Social" 4 | var variables = window.Umbraco.Sys.ServerVariables.skybrudSocial; 5 | 6 | $scope.editorState = editorState.current; 7 | 8 | // Define an alias for the editor (eg. used for callbacks) 9 | var alias = $scope.alias = ("skybrudsocial_" + Math.random()).replace(".", ""); 10 | 11 | $scope.authenticate = function () { 12 | var url = variables.surfaceBaseUrl + "FacebookOAuth/Authenticate?callback=" + alias + "&contentTypeAlias=" + editorState.current.contentTypeAlias + "&propertyAlias=" + $scope.model.alias; 13 | window.open(url, "Authenticate with Facebook", "scrollbars=no,resizable=yes,menubar=no,width=800,height=700"); 14 | }; 15 | 16 | $scope.reset = function() { 17 | $scope.model.value = null; 18 | }; 19 | 20 | window[alias] = function (data) { 21 | $scope.$apply(function () { 22 | $scope.model.value = data; 23 | }); 24 | } 25 | 26 | }); -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Scripts/Mailchimp/OAuth.js: -------------------------------------------------------------------------------- 1 | angular.module("umbraco").controller("Skybrud.Social.Mailchimp.OAuth.Controller", function ($scope, $element, editorState) { 2 | 3 | // Get the server variables for "Skybrud.Social" 4 | var variables = window.Umbraco.Sys.ServerVariables.skybrudSocial; 5 | 6 | $scope.editorState = editorState.current; 7 | 8 | // Define an alias for the editor (eg. used for callbacks) 9 | var alias = $scope.alias = ("skybrudsocial_" + Math.random()).replace(".", ""); 10 | 11 | $scope.authenticate = function () { 12 | var url = variables.surfaceBaseUrl + "MailchimpOAuth/Authenticate?callback=" + alias + "&contentTypeAlias=" + editorState.current.contentTypeAlias + "&propertyAlias=" + $scope.model.alias; 13 | window.open(url, "Authenticate with Mailchimp", "scrollbars=no,resizable=yes,menubar=no,width=800,height=700"); 14 | }; 15 | 16 | $scope.reset = function() { 17 | $scope.model.value = null; 18 | }; 19 | 20 | window[alias] = function (data) { 21 | $scope.$apply(function () { 22 | $scope.model.value = data; 23 | }); 24 | } 25 | 26 | }); -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Views/Facebook/OAuth.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 |
6 |
7 | 11 |
12 |
13 |
14 | {{model.value.user.name}} (ID: {{model.value.user.id}}) 15 |
16 | 17 |
18 |
19 |
20 |
-------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27703.2035 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Skybrud.Social.Umbraco", "Skybrud.Social.Umbraco\Skybrud.Social.Umbraco.csproj", "{1543F539-657A-4782-8232-719910026973}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1543F539-657A-4782-8232-719910026973}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {1543F539-657A-4782-8232-719910026973}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {1543F539-657A-4782-8232-719910026973}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {1543F539-657A-4782-8232-719910026973}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {DCCDE290-B6DE-469D-8BB6-7AC9ECFF4E11} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /skybrud.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": { 3 | "postBuild": [ 4 | { 5 | "alias": "zip", 6 | "destination": "releases/github/{packageName}.v{version}.zip", 7 | "files": [ 8 | { 9 | "source": "src/{packageName}/bin/Release/net472/", 10 | "destination": "bin/", 11 | "patterns": [ 12 | "{packageName}.dll", 13 | "{packageName}.xml", 14 | "Skybrud.Essentials.dll", 15 | "Skybrud.Essentials.xml", 16 | "Skybrud.Essentials.Http.dll", 17 | "Skybrud.Essentials.Http.xml", 18 | "Skybrud.Social.Core.dll", 19 | "Skybrud.Social.Facebook.dll", 20 | "Skybrud.Social.Google.dll", 21 | "Skybrud.Social.Mailchimp.dll" 22 | ] 23 | }, 24 | { 25 | "source": "src/{packageName}/App_Plugins/Skybrud.Social", 26 | "destination": "App_Plugins/Skybrud.Social/", 27 | "patterns": [ 28 | "**/*.js", 29 | "**/*.css", 30 | "**/*.html", 31 | "**/*.xml", 32 | "package.manifest" 33 | ] 34 | } 35 | ] 36 | } 37 | ] 38 | } 39 | } -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Models/Mvc/PageModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Skybrud.Social.Facebook.Models.Users; 3 | using Skybrud.Social.Mailchimp.Models.Authentication; 4 | 5 | namespace Skybrud.Social.Umbraco.Models.Mvc { 6 | 7 | public class PageModel { 8 | 9 | public string Title { get; set; } 10 | 11 | } 12 | 13 | public class ErrorPageModel : PageModel { 14 | 15 | public string Message { get; set; } 16 | 17 | public Exception Exception { get; set; } 18 | 19 | } 20 | 21 | public class FacebookAuthenticatedPageModel : PageModel { 22 | 23 | public FacebookUser User { get; set; } 24 | 25 | public string Callback { get; set; } 26 | 27 | public object CallbackData { get; set; } 28 | 29 | } 30 | 31 | public class MailchimpAuthenticatedPageModel : PageModel { 32 | 33 | public MailchimpMetadata Meta { get; set; } 34 | 35 | public string Callback { get; set; } 36 | 37 | public object CallbackData { get; set; } 38 | 39 | } 40 | 41 | //public class GoogleAuthenticatedPageModel : PageModel { 42 | 43 | // public string Callback { get; set; } 44 | 45 | // public GoogleOAuthData CallbackData { get; set; } 46 | 47 | //} 48 | 49 | } -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Views/Google/OAuthScopes.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

4 | {{group.name}} 5 | ({{group.count}} of {{group.scopes.length}} selected) 6 | 7 |

8 | 9 | 10 | 11 | 20 | 21 | 22 |
12 | 19 |
23 |
24 |
-------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/compilerconfig.json.defaults: -------------------------------------------------------------------------------- 1 | { 2 | "compilers": { 3 | "less": { 4 | "autoPrefix": "", 5 | "cssComb": "none", 6 | "ieCompat": true, 7 | "strictMath": false, 8 | "strictUnits": false, 9 | "relativeUrls": true, 10 | "rootPath": "", 11 | "sourceMapRoot": "", 12 | "sourceMapBasePath": "", 13 | "sourceMap": false 14 | }, 15 | "sass": { 16 | "autoPrefix": "", 17 | "includePath": "", 18 | "indentType": "space", 19 | "indentWidth": 2, 20 | "outputStyle": "nested", 21 | "Precision": 5, 22 | "relativeUrls": true, 23 | "sourceMapRoot": "", 24 | "lineFeed": "", 25 | "sourceMap": false 26 | }, 27 | "stylus": { 28 | "sourceMap": false 29 | }, 30 | "babel": { 31 | "sourceMap": false 32 | }, 33 | "coffeescript": { 34 | "bare": false, 35 | "runtimeMode": "node", 36 | "sourceMap": false 37 | }, 38 | "handlebars": { 39 | "root": "", 40 | "noBOM": false, 41 | "name": "", 42 | "namespace": "", 43 | "knownHelpersOnly": false, 44 | "forcePartial": false, 45 | "knownHelpers": [], 46 | "commonjs": "", 47 | "amd": false, 48 | "sourceMap": false 49 | } 50 | }, 51 | "minifiers": { 52 | "css": { 53 | "enabled": true, 54 | "termSemicolons": true, 55 | "gzip": false 56 | }, 57 | "javascript": { 58 | "enabled": true, 59 | "termSemicolons": true, 60 | "gzip": false 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Skybrud.Social for Umbraco 7 2 | ============================ 3 | [Skybrud.Social](https://github.com/abjerner/Skybrud.Social) is a framework in .NET that integrates with a number of social services. This repository is for a package for Umbraco 8 that will use Skybrud.Social for bringing stuff like OAuth authentication to Umbraco. 4 | 5 | **Umbraco 7?** 6 | This package was originally developed for Umbraco 7. You can find that version in the [**dev-v7**](https://github.com/abjerner/Skybrud.Social.Umbraco/blob/dev-v7/README.md) branch 7 | 8 | **Umbraco 6?** 9 | If you're using Umbraco 6, have a look at [this package](https://github.com/abjerner/Skybrud.Social-for-Umbraco). The package for Umbraco 6 is no longer maintained. 10 | 11 | ### Installation 12 | 13 | 1. [**NuGet Package**][NuGetPackageUrl] 14 | Install this NuGet package in your Visual Studio project. Makes updating easy. 15 | 16 | 18 | 19 | 3. [**ZIP file**][GitHubReleaseUrl] 20 | Manually unzip and move files to the root directory of your website. 21 | 22 | 25 | 26 | 27 | 28 | [NuGetPackageUrl]: https://www.nuget.org/packages/Skybrud.Social.Umbraco 29 | [UmbracoPackageUrl]: http://our.umbraco.org/projects/website-utilities/skybrudsocial-for-umbraco-7 30 | [GitHubReleaseUrl]: https://github.com/abjerner/Skybrud.Social.Umbraco/releases/latest 31 | [TwitterIntent]: https://twitter.com/intent/tweet?screen_name=abjerner&text=Hey%20there.%20If%20I%27ll%20give%20you%20my%20first%20born,%20will%20you... 32 | [OurNewTopic]: http://our.umbraco.org/projects/website-utilities/skybrudsocial-for-umbraco-7/general-discussion 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Scripts/Google/OAuthScopes.js: -------------------------------------------------------------------------------- 1 | angular.module("umbraco").controller("Skybrud.Social.Google.OAuthScopes.Controller", function ($scope, $http, editorService) { 2 | 3 | // Get the server variables for "Skybrud.Social" 4 | var variables = window.Umbraco.Sys.ServerVariables.skybrudSocial; 5 | 6 | // Make sure we have an array for the selected scopes 7 | if (!Array.isArray($scope.model.value)) $scope.model.value = ["email", "profile"]; 8 | 9 | // Shadow array for keeping track of the selected scopes 10 | $scope.scopes = []; 11 | 12 | $scope.loading = true; 13 | 14 | $http.get(variables.webApiBaseUrl + "Google/GetScopes").then(function(res) { 15 | 16 | $scope.scopes = res.data; 17 | 18 | $scope.scopes.forEach(function (group, g) { 19 | group.count = 0; 20 | group.expanded = g === 0; 21 | group.scopes.forEach(function (scope) { 22 | scope.selected = $scope.model.value.indexOf(scope.alias) >= 0; 23 | if (scope.selected) { 24 | group.expanded = true; 25 | group.count++; 26 | } 27 | }); 28 | }); 29 | 30 | $scope.loading = false; 31 | 32 | }); 33 | 34 | $scope.toggle = function (scope) { 35 | 36 | scope.selected = !scope.selected; 37 | 38 | update(); 39 | 40 | }; 41 | 42 | function update() { 43 | 44 | var temp = []; 45 | 46 | $scope.scopes.forEach(function (group) { 47 | group.count = 0; 48 | group.scopes.forEach(function (scope) { 49 | if (scope.selected) { 50 | temp.push(scope.alias); 51 | group.count++; 52 | } 53 | }); 54 | }); 55 | 56 | $scope.model.value = temp; 57 | 58 | } 59 | 60 | }); -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Views/Layout.cshtml: -------------------------------------------------------------------------------- 1 | @inherits System.Web.Mvc.WebViewPage 2 | 3 | 4 | 5 | 6 | 7 | @Model.Title - Skybrud.Social 8 | @**@ 9 | 10 | 11 | 12 | 47 | 48 | 49 | @*
*@ 50 |
51 |
Umbraco
52 |
Skybrud.Social
53 |
54 |
55 | @RenderBody() 56 |
57 | 58 | -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Models/Google/GoogleScopeGroup.cs: -------------------------------------------------------------------------------- 1 | //using System.Collections.Generic; 2 | //using System.Linq; 3 | //using Newtonsoft.Json; 4 | //using Skybrud.Social.Gmail.Scopes; 5 | //using Skybrud.Social.Google.Analytics.Scopes; 6 | //using Skybrud.Social.Google.Scopes; 7 | //using Skybrud.Social.GoogleCalendar.Scopes; 8 | //using Skybrud.Social.GoogleDrive.Scopes; 9 | //using Skybrud.Social.YouTube.Scopes; 10 | 11 | //namespace Skybrud.Social.Umbraco.Models.Google { 12 | 13 | // public class GoogleScopeGroup { 14 | 15 | // [JsonProperty("name")] 16 | // public string Name { get; set; } 17 | 18 | // [JsonProperty("scopes")] 19 | // public GoogleScopeItem[] Scopes { get; set; } 20 | 21 | // public GoogleScopeGroup(string name, params GoogleScope[] scope) { 22 | // Name = name; 23 | // Scopes = scope.Select(x => new GoogleScopeItem(x)).ToArray(); 24 | // } 25 | 26 | // public static GoogleScopeGroup[] GetAll() { 27 | 28 | // List groups = new List(); 29 | 30 | // groups.Add(new GoogleScopeGroup("Basic", GoogleScopes.All)); 31 | // groups.Add(new GoogleScopeGroup("Analytics", AnalyticsScopes.All)); 32 | // groups.Add(new GoogleScopeGroup("Calendar", CalendarScopes.All)); 33 | // groups.Add(new GoogleScopeGroup("Drive", DriveScopes.All)); 34 | // groups.Add(new GoogleScopeGroup("Gmail", GmailScopes.All)); 35 | // groups.Add(new GoogleScopeGroup("YouTube", YouTubeScopes.All)); 36 | 37 | // return groups.ToArray(); 38 | 39 | // } 40 | 41 | // } 42 | 43 | // public class GoogleScopeItem { 44 | 45 | // [JsonProperty("alias")] 46 | // public string Alias { get; set; } 47 | 48 | // [JsonProperty("name")] 49 | // public string Name { get; set; } 50 | 51 | // [JsonProperty("description")] 52 | // public string Description { get; set; } 53 | 54 | // public GoogleScopeItem(GoogleScope scope) { 55 | // Alias = scope.Alias; 56 | // Name = scope.Name; 57 | // Description = scope.Description; 58 | // } 59 | 60 | // } 61 | 62 | //} -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/DataTypes/MailchimpOAuthDataPropertyValueConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Skybrud.Social.Umbraco.Models.Mailchimp; 3 | using Umbraco.Core.Models.PublishedContent; 4 | using Umbraco.Core.PropertyEditors; 5 | 6 | namespace Skybrud.Social.Umbraco.DataTypes { 7 | 8 | class MailchimpOAuthDataPropertyValueConverter : PropertyValueConverterBase { 9 | 10 | public override bool IsConverter(PublishedPropertyType propertyType) { 11 | 12 | switch (propertyType.EditorAlias) { 13 | 14 | case "Skybrud.Social.GoogleOAuth": 15 | case "Skybrud.Social.MailchimpOAuth": 16 | return true; 17 | 18 | default: 19 | return false; 20 | 21 | } 22 | 23 | } 24 | 25 | public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { 26 | 27 | switch (propertyType.EditorAlias) { 28 | 29 | //case "Skybrud.Social.GoogleOAuth": 30 | // return GoogleOAuthData.Deserialize(source as string); 31 | 32 | case "Skybrud.Social.MailchimpOAuth": 33 | return MailchimpOAuthData.Deserialize(source as string); 34 | 35 | default: 36 | return null; 37 | 38 | } 39 | 40 | } 41 | 42 | public override object ConvertIntermediateToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { 43 | return inter; 44 | } 45 | 46 | public override object ConvertIntermediateToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { 47 | return null; 48 | } 49 | 50 | public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) => PropertyCacheLevel.None; 51 | 52 | public override Type GetPropertyValueType(PublishedPropertyType propertyType) { 53 | 54 | switch (propertyType.EditorAlias) { 55 | 56 | //case "Skybrud.Social.GoogleOAuth": 57 | // return typeof(GoogleOAuthData); 58 | 59 | case "Skybrud.Social.MailchimpOAuth": 60 | return typeof(MailchimpOAuthData); 61 | 62 | default: 63 | return typeof(object); 64 | 65 | } 66 | 67 | } 68 | 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Models/Mailchimp/MailchimpOAuthData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Linq; 4 | using Skybrud.Essentials.Json; 5 | using Skybrud.Essentials.Json.Extensions; 6 | using Skybrud.Essentials.Time; 7 | using Skybrud.Social.Mailchimp; 8 | using Skybrud.Social.Mailchimp.Models.Authentication; 9 | using Skybrud.Social.Umbraco.Controllers.Surface; 10 | 11 | namespace Skybrud.Social.Umbraco.Models.Mailchimp { 12 | 13 | public class MailchimpOAuthData { 14 | 15 | #region Properties 16 | 17 | [JsonProperty("authenticatedAt")] 18 | public EssentialsTime AuthenticatedAt { get; } 19 | 20 | [JsonProperty("accessToken")] 21 | public string AccessToken { get; } 22 | 23 | [JsonProperty("meta")] 24 | [JsonConverter(typeof(JsonObjectBaseConverter))] 25 | public MailchimpMetadata Metadata { get; } 26 | 27 | /// 28 | /// Gets whether the property value contains information about an authenticated Mailchimp user. 29 | /// 30 | [JsonIgnore] 31 | public bool IsAuthenticated => String.IsNullOrWhiteSpace(AccessToken) == false && String.IsNullOrWhiteSpace(Metadata?.ApiEndpoint) == false; 32 | 33 | #endregion 34 | 35 | #region Constructors 36 | 37 | internal MailchimpOAuthData(MailchimpTokenInfo token, MailchimpMetadata meta) { 38 | AuthenticatedAt = EssentialsTime.UtcNow; 39 | AccessToken = token.AccessToken; 40 | Metadata = meta; 41 | } 42 | 43 | public MailchimpOAuthData(JObject obj) { 44 | AuthenticatedAt = obj.GetString("authenticatedAt", EssentialsTime.Parse); 45 | AccessToken = obj.GetString("accessToken"); 46 | Metadata = obj.GetObject("meta", MailchimpMetadata.Parse); 47 | } 48 | 49 | #endregion 50 | 51 | #region Member methods 52 | 53 | public MailchimpService GetService() { 54 | if (IsAuthenticated) throw new Exception("User is not authenticated"); 55 | return MailchimpService.GetFromAccessToken(AccessToken, Metadata.ApiEndpoint); 56 | } 57 | 58 | #endregion 59 | 60 | #region Static methods 61 | 62 | public static MailchimpOAuthData Parse(JObject obj) { 63 | return obj == null ? null : new MailchimpOAuthData(obj); 64 | 65 | } 66 | 67 | public static MailchimpOAuthData Deserialize(string value) { 68 | try { 69 | return Parse(JsonUtils.ParseJsonObject(value)); 70 | } catch { 71 | return Parse(new JObject()); 72 | } 73 | } 74 | 75 | #endregion 76 | 77 | } 78 | 79 | } -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Models/Facebook/FacebookOAuthData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Linq; 4 | using Skybrud.Essentials.Json; 5 | using Skybrud.Essentials.Json.Converters.Time; 6 | using Skybrud.Essentials.Json.Extensions; 7 | using Skybrud.Essentials.Time; 8 | using Skybrud.Social.Facebook; 9 | using Skybrud.Social.Facebook.Models.Authentication; 10 | using Skybrud.Social.Facebook.Models.Users; 11 | using Skybrud.Social.Umbraco.Controllers.Surface; 12 | 13 | namespace Skybrud.Social.Umbraco.Models.Facebook { 14 | 15 | public class FacebookOAuthData { 16 | 17 | #region Properties 18 | 19 | [JsonProperty("authenticatedAt")] 20 | public EssentialsTime AuthenticatedAt { get; } 21 | 22 | [JsonProperty("accessToken")] 23 | public string AccessToken { get; } 24 | 25 | [JsonProperty("expiresIn")] 26 | [JsonConverter(typeof(TimeSpanSecondsConverter))] 27 | public TimeSpan ExpiresIn { get; } 28 | 29 | [JsonProperty("user")] 30 | [JsonConverter(typeof(JsonObjectBaseConverter))] 31 | public FacebookUser User { get; } 32 | 33 | /// 34 | /// Gets whether the property value contains information about an authenticated Facebook user. 35 | /// 36 | [JsonIgnore] 37 | public bool IsAuthenticated => String.IsNullOrWhiteSpace(AccessToken); 38 | 39 | #endregion 40 | 41 | #region Constructors 42 | 43 | internal FacebookOAuthData(FacebookToken token, FacebookUser user) { 44 | AuthenticatedAt = EssentialsTime.UtcNow; 45 | AccessToken = token.AccessToken; 46 | ExpiresIn = token.ExpiresIn; 47 | User = user; 48 | } 49 | 50 | public FacebookOAuthData(JObject obj) { 51 | AuthenticatedAt = obj.GetString("authenticatedAt", EssentialsTime.Parse); 52 | AccessToken = obj.GetString("accessToken"); 53 | ExpiresIn = obj.GetDouble("expiresIn", TimeSpan.FromSeconds); 54 | User = obj.GetObject("user", FacebookUser.Parse); 55 | } 56 | 57 | #endregion 58 | 59 | #region Member methods 60 | 61 | public FacebookService GetService() { 62 | if (IsAuthenticated) throw new Exception("User is not authenticated"); 63 | return FacebookService.CreateFromAccessToken(AccessToken); 64 | } 65 | 66 | #endregion 67 | 68 | #region Static methods 69 | 70 | public static FacebookOAuthData Parse(JObject obj) { 71 | return obj == null ? null : new FacebookOAuthData(obj); 72 | 73 | } 74 | 75 | public static FacebookOAuthData Deserialize(string value) { 76 | try { 77 | return Parse(JsonUtils.ParseJsonObject(value)); 78 | } catch { 79 | return Parse(new JObject()); 80 | } 81 | } 82 | 83 | #endregion 84 | 85 | } 86 | 87 | } -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Skybrud.Social.Umbraco.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net472 5 | 6 | 7 | 8 | 2.0.0-alpha001 9 | Skybrud.dk a/s 10 | Skybrud.Social 11 | Anders Bjerner 12 | Copyright © 2019 13 | Package for integration with Skybrud.Social and the Umbraco 8 backoffice. 14 | 15 | 16 | 17 | git 18 | https://github.com/abjerner/Skybrud.Social.Umbraco 19 | 20 | 21 | 22 | Umbraco, Facebook, Twitter, Instagram, Google, Analytics, Skybrud, Social, OAuth 23 | MIT 24 | https://github.com/abjerner/Skybrud.Social.Umbraco 25 | https://www.skybrud.dk/img/5431sk/icon/favicon.ico 26 | 27 | 28 | 29 | 30 | 31 | Default.less 32 | 33 | 34 | Default.css 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | ..\assemblies\Skybrud.Social.Mailchimp.dll 48 | 49 | 50 | 51 | 52 | 53 | 54 | all 55 | 56 | 57 | all 58 | 59 | 60 | 61 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Models/Google/GoogleOAuthData.cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using Newtonsoft.Json; 5 | //using Newtonsoft.Json.Linq; 6 | //using Skybrud.Essentials.Json; 7 | //using Skybrud.Essentials.Json.Extensions; 8 | //using Skybrud.Essentials.Time; 9 | //using Skybrud.Social.Google; 10 | //using Skybrud.Social.Google.Analytics.Scopes; 11 | //using Skybrud.Social.Google.Models; 12 | //using Skybrud.Social.Google.Models.Authentication; 13 | //using Skybrud.Social.Google.Scopes; 14 | //using Skybrud.Social.Umbraco.Controllers.Surface; 15 | //using Skybrud.Social.Umbraco.Json.Converters; 16 | 17 | //namespace Skybrud.Social.Umbraco.Models.Google { 18 | 19 | // public class GoogleOAuthData { 20 | 21 | // #region Properties 22 | 23 | // [JsonProperty("authenticatedAt")] 24 | // public EssentialsTime AuthenticatedAt { get; } 25 | 26 | // /// 27 | // /// Gets the client ID of the app used to authenticate the user. 28 | // /// 29 | // [JsonProperty("clinetId")] 30 | // public string ClientId { get; set; } 31 | 32 | // /// 33 | // /// Gets the client secret of the app used to authenticate the user. 34 | // /// 35 | // [JsonProperty("clientSecret")] 36 | // public string ClientSecret { get; set; } 37 | 38 | // [JsonProperty("accessToken")] 39 | // public string AccessToken { get; } 40 | 41 | // [JsonProperty("refreshToken")] 42 | // public string RefreshToken { get; } 43 | 44 | // [JsonProperty("scope")] 45 | // [JsonConverter(typeof(SocialJsonConverter))] 46 | // public GoogleScope[] Scope { get; } 47 | 48 | // [JsonProperty("user")] 49 | // [JsonConverter(typeof(JsonObjectBaseConverter))] 50 | // public GoogleUserInfo User { get; } 51 | 52 | // /// 53 | // /// Gets whether the property value contains information about an authenticated Google user. 54 | // /// 55 | // [JsonIgnore] 56 | // public bool IsAuthenticated => String.IsNullOrWhiteSpace(RefreshToken) != false && User != null; 57 | 58 | // #endregion 59 | 60 | // #region Constructors 61 | 62 | // internal GoogleOAuthData(string clientId, string clientSecret, GoogleToken token, GoogleUserInfo user) { 63 | // AuthenticatedAt = EssentialsTime.UtcNow; 64 | // ClientId = clientId; 65 | // ClientSecret = clientSecret; 66 | // AccessToken = token.AccessToken; 67 | // RefreshToken = token.RefreshToken; 68 | // Scope = GoogleUtils.ParseScopes(token.JObject.GetString("scope")); 69 | // User = user; 70 | // } 71 | 72 | // private GoogleOAuthData(JObject obj) { 73 | // AuthenticatedAt = obj.GetString("authenticatedAt", EssentialsTime.Parse); 74 | // ClientId = obj.GetString("clientId"); 75 | // ClientSecret = obj.GetString("clientSecret"); 76 | // AccessToken = obj.GetString("accessToken"); 77 | // RefreshToken = obj.GetString("refreshToken"); 78 | // Scope = GoogleUtils.ParseScopes(obj.GetString("scope")); 79 | // User = obj.GetObject("user", GoogleUserInfo.Parse); 80 | // } 81 | 82 | // #endregion 83 | 84 | // #region Member methods 85 | 86 | // public GoogleService GetService() { 87 | // if (IsAuthenticated) throw new Exception("User is not authenticated"); 88 | // return GoogleService.CreateFromRefreshToken(ClientId, ClientSecret, RefreshToken); 89 | // } 90 | 91 | // #endregion 92 | 93 | // #region Static methods 94 | 95 | // public static GoogleOAuthData Parse(JObject obj) { 96 | // return obj == null ? null : new GoogleOAuthData(obj); 97 | 98 | // } 99 | 100 | // public static GoogleOAuthData Deserialize(string value) { 101 | // try { 102 | // return Parse(JsonUtils.ParseJsonObject(value)); 103 | // } catch { 104 | // return Parse(new JObject()); 105 | // } 106 | // } 107 | 108 | // #endregion 109 | 110 | // } 111 | 112 | //} -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/package.manifest: -------------------------------------------------------------------------------- 1 | { 2 | "javascript": [ 3 | "/App_Plugins/Skybrud.Social/Scripts/Facebook/OAuth.js", 4 | "/App_Plugins/Skybrud.Social/Scripts/Google/OAuth.js", 5 | "/App_Plugins/Skybrud.Social/Scripts/Google/OAuthScopes.js", 6 | "/App_Plugins/Skybrud.Social/Scripts/Mailchimp/OAuth.js" 7 | ], 8 | "css": [ 9 | "/App_Plugins/Skybrud.Social/Styles/Default.css" 10 | ], 11 | "propertyEditors": [ 12 | { 13 | "alias": "Skybrud.Social.GoogleOAuth", 14 | "editor": { 15 | "view": "/App_Plugins/Skybrud.Social/Views/Google/OAuth.html", 16 | "hideLabel": false, 17 | "valueType": "JSON" 18 | }, 19 | "name": "Skybrud.Social - Google OAuth", 20 | "icon": "icon-home", 21 | "group": "Skybrud.Social", 22 | "prevalues": { 23 | "fields": [ 24 | { 25 | "key": "info", 26 | "label": "Info", 27 | "view": "/App_Plugins/Skybrud.Social/Views/Google/OAuthInfo.html" 28 | }, 29 | { 30 | "key": "clientId", 31 | "label": "Client ID", 32 | "description": "The ID of your Google client/application.", 33 | "view": "textstring" 34 | }, 35 | { 36 | "key": "clientSecret", 37 | "label": "Client Secret", 38 | "description": "The secret of your Google client/application.", 39 | "view": "textstring" 40 | }, 41 | { 42 | "key": "redirectUri", 43 | "label": "Redirect URI", 44 | "description": "The redirect URI of your Google client/application.", 45 | "view": "textstring" 46 | }, 47 | { 48 | "key": "scopes", 49 | "label": "Scopes", 50 | "description": "Select the scope/permissions the user should accept when authenticationg.

The scope determines how you can read from and white to the various Google APIs.", 51 | "view": "/App_Plugins/Skybrud.Social/Views/Google/OAuthScopes.html" 52 | } 53 | ] 54 | } 55 | }, 56 | { 57 | "alias": "Skybrud.Social.MailchimpOAuth", 58 | "editor": { 59 | "view": "/App_Plugins/Skybrud.Social/Views/Mailchimp/OAuth.html", 60 | "hideLabel": false, 61 | "valueType": "JSON" 62 | }, 63 | "name": "Skybrud.Social - Mailchimp OAuth", 64 | "icon": "icon-home", 65 | "group": "Skybrud.Social", 66 | "prevalues": { 67 | "fields": [ 68 | { 69 | "key": "clientId", 70 | "label": "Client ID", 71 | "view": "textstring" 72 | }, 73 | { 74 | "key": "clientSecret", 75 | "label": "Client Secret", 76 | "view": "textstring" 77 | }, 78 | { 79 | "key": "redirectUri", 80 | "label": "Redirect URI", 81 | "view": "textstring" 82 | } 83 | ] 84 | } 85 | }, 86 | { 87 | "alias": "Skybrud.Social.FacebookOAuth", 88 | "editor": { 89 | "view": "/App_Plugins/Skybrud.Social/Views/Facebook/OAuth.html", 90 | "hideLabel": false, 91 | "valueType": "JSON" 92 | }, 93 | "name": "Skybrud.Social - Facebook OAuth", 94 | "icon": "icon-home color-black", 95 | "group": "Skybrud.Social", 96 | "prevalues": { 97 | "fields": [ 98 | { 99 | "key": "clientId", 100 | "label": "Client ID", 101 | "view": "textstring" 102 | }, 103 | { 104 | "key": "clientSecret", 105 | "label": "Client Secret", 106 | "view": "textstring" 107 | }, 108 | { 109 | "key": "redirectUri", 110 | "label": "Redirect URI", 111 | "view": "textstring" 112 | } 113 | ] 114 | } 115 | } 116 | ], 117 | "gridEditors": [ 118 | { 119 | "name": "Headline", 120 | "alias": "headline", 121 | "icon": "icon-coin", 122 | "view": "textstring", 123 | "config": { 124 | "style": "font-size: 36px; line-height: 45px; font-weight: bold", 125 | "markup": "

#value#

" 126 | } 127 | } 128 | ] 129 | } -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Controllers/Surface/FacebookOAuthController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using Microsoft.Owin.Security; 7 | using Skybrud.Social.Facebook; 8 | using Skybrud.Social.Facebook.Models.Authentication; 9 | using Skybrud.Social.Facebook.Models.Users; 10 | using Skybrud.Social.Facebook.OAuth; 11 | using Skybrud.Social.Facebook.Options.User; 12 | using Skybrud.Social.Mailchimp.Models.Authentication; 13 | using Skybrud.Social.Mailchimp.OAuth; 14 | using Skybrud.Social.Umbraco.Constants; 15 | using Skybrud.Social.Umbraco.Models.Facebook; 16 | using Skybrud.Social.Umbraco.Models.Mailchimp; 17 | using Skybrud.Social.Umbraco.Models.Mvc; 18 | using Umbraco.Core.Composing; 19 | using Umbraco.Core.Logging; 20 | using Umbraco.Core.Models; 21 | using Umbraco.Web.Mvc; 22 | using Umbraco.Web.Security; 23 | 24 | namespace Skybrud.Social.Umbraco.Controllers.Surface { 25 | 26 | [PluginController(SocialConstants.PluginController)] 27 | public class FacebookOAuthController : SurfaceController { 28 | 29 | private string _state; 30 | 31 | #region Properties 32 | 33 | /// 34 | /// Gets the authorization code from the query string (if specified). 35 | /// 36 | public string AuthCode => Request.QueryString["code"]; 37 | 38 | public string AuthState => Request.QueryString["state"]; 39 | 40 | public string AuthErrorReason => Request.QueryString["error_reason"]; 41 | 42 | public string AuthError => Request.QueryString["error"]; 43 | 44 | public bool HasAuthError => String.IsNullOrWhiteSpace(AuthError) == false; 45 | 46 | public string AuthErrorDescription => Request.QueryString["error_description"]; 47 | 48 | public string State { 49 | get => _state ?? Request.QueryString["state"]; 50 | set => _state = value; 51 | } 52 | 53 | public bool HasState => String.IsNullOrWhiteSpace(State) == false; 54 | 55 | public FacebookOAuthState SessionState => HasState ? Session["Skybrud.Social_" + State] as FacebookOAuthState : null; 56 | 57 | public bool HasSessionState => SessionState != null; 58 | 59 | public string Callback => HasSessionState ? SessionState.Callback : Request.QueryString["callback"]; 60 | 61 | #endregion 62 | 63 | #region Public API methods 64 | 65 | public ActionResult Authenticate(string contentTypeAlias, string propertyAlias) { 66 | 67 | // Did we receive an error callback from Google? 68 | if (HasAuthError) { 69 | return Error("Authentication failed", "The authentication with Facebook failed. Close this window and try again."); 70 | } 71 | 72 | // Handle Umbraco authentication stuff 73 | HttpContextWrapper http = new HttpContextWrapper(System.Web.HttpContext.Current); 74 | AuthenticationTicket ticket = http.GetUmbracoAuthTicket(); 75 | 76 | // User must be logged in 77 | if (http.AuthenticateCurrentRequest(ticket, true) == false) { 78 | return Error("Not logged in", "You must be logged in to Umbraco to access this page. Close this window and try again."); 79 | } 80 | 81 | // Do we have a valid session? 82 | if (HasState && SessionState == null) { 83 | return Error("Session expired?", "It seems that your browser session has expired. You can try to close this window and try again."); 84 | } 85 | 86 | if (HasSessionState) { 87 | contentTypeAlias = SessionState.ContentTypeAlias; 88 | propertyAlias = SessionState.PropertyAlias; 89 | } 90 | 91 | IContentType ct = Current.Services.ContentTypeService.Get(contentTypeAlias); 92 | if (ct == null) return Error("Oooops", "Specified content type was not found."); 93 | 94 | PropertyType property = ct.PropertyTypes.FirstOrDefault(x => x.Alias == propertyAlias); 95 | if (property == null) return Error("Oooops", "Property not found."); 96 | 97 | IDataType dt = Current.Services.DataTypeService.GetDataType(property.DataTypeId); 98 | 99 | Dictionary config = dt.ConfigurationAs>(); 100 | 101 | config.TryGetValue("clientId", out object clientIdObject); 102 | config.TryGetValue("clientSecret", out object clientSecretObject); 103 | config.TryGetValue("redirectUri", out object redirectUriObject); 104 | 105 | string clientId = clientIdObject?.ToString(); 106 | string clientSecret = clientSecretObject?.ToString(); 107 | string redirectUri = redirectUriObject?.ToString(); 108 | 109 | if (String.IsNullOrWhiteSpace(clientId)) return Error("Oooops", "Invalid data type configuration."); 110 | if (String.IsNullOrWhiteSpace(clientSecret)) return Error("Oooops", "Invalid data type configuration."); 111 | if (String.IsNullOrWhiteSpace(redirectUri)) return Error("Oooops", "Invalid data type configuration."); 112 | 113 | // Initialize a new OAuth client 114 | FacebookOAuthClient client = new FacebookOAuthClient(clientId, clientSecret, redirectUri); 115 | 116 | // Redirect the user to the login dialog 117 | if (AuthCode == null) { 118 | 119 | // Generate a new unique/random state 120 | State = Guid.NewGuid().ToString(); 121 | 122 | // Save the state in the current user session 123 | Session["Skybrud.Social_" + State] = new FacebookOAuthState { 124 | Callback = Callback, 125 | ContentTypeAlias = contentTypeAlias, 126 | PropertyAlias = propertyAlias 127 | }; 128 | 129 | // Construct the authorization URL 130 | string url = client.GetAuthorizationUrl(State); 131 | 132 | // Redirect the user 133 | return Redirect(url); 134 | 135 | } 136 | 137 | // Exchange the authorization code for an access token 138 | FacebookToken info; 139 | try { 140 | info = client.GetAccessTokenFromAuthCode(AuthCode).Body; 141 | } catch (Exception ex) { 142 | Logger.Error(ex, "Unable to acquire access token."); 143 | return Error("Authentication failed", "Unable to acquire access token.", ex); 144 | } 145 | 146 | try { 147 | 148 | // Initialize a new Facebook service (no calls are made here) 149 | FacebookService service = FacebookService.CreateFromAccessToken(info.AccessToken); 150 | 151 | // Make a request to the Facebook API to get information about the user 152 | FacebookUser user = service.Users.GetUser("me").Body; 153 | 154 | // Set the callback data 155 | FacebookOAuthData data = new FacebookOAuthData(info, user); 156 | 157 | return View("~/App_Plugins/Skybrud.Social/Views/Facebook/AuthenticateSuccess.cshtml", new FacebookAuthenticatedPageModel { 158 | Title = "Auhentication", 159 | User = user, 160 | Callback = Callback, 161 | CallbackData = data 162 | }); 163 | 164 | } catch (Exception ex) { 165 | 166 | Logger.Error(ex, "Unable to get user information."); 167 | 168 | return Error("Authenticated failed", "Unable to get user information.", ex); 169 | 170 | } 171 | 172 | } 173 | 174 | private ActionResult Error(string title, string message, Exception exception = null) { 175 | return View("~/App_Plugins/Skybrud.Social/Views/AuthenticateError.cshtml", new ErrorPageModel { 176 | Title = title, 177 | Message = message, 178 | Exception = exception 179 | }); 180 | } 181 | 182 | #endregion 183 | 184 | } 185 | 186 | } -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Controllers/Surface/MailchimpOAuthController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using Microsoft.Owin.Security; 7 | using Skybrud.Social.Mailchimp.Models.Authentication; 8 | using Skybrud.Social.Mailchimp.OAuth; 9 | using Skybrud.Social.Umbraco.Constants; 10 | using Skybrud.Social.Umbraco.Models.Mailchimp; 11 | using Skybrud.Social.Umbraco.Models.Mvc; 12 | using Umbraco.Core.Composing; 13 | using Umbraco.Core.Logging; 14 | using Umbraco.Core.Models; 15 | using Umbraco.Web.Mvc; 16 | using Umbraco.Web.Security; 17 | 18 | namespace Skybrud.Social.Umbraco.Controllers.Surface { 19 | 20 | [PluginController(SocialConstants.PluginController)] 21 | public class MailchimpOAuthController : SurfaceController { 22 | 23 | private string _state; 24 | 25 | #region Properties 26 | 27 | /// 28 | /// Gets the authorization code from the query string (if specified). 29 | /// 30 | public string AuthCode => Request.QueryString["code"]; 31 | 32 | /// 33 | /// Gets the OAuth state parameter from the query string. 34 | /// 35 | public string AuthState => Request.QueryString["state"]; 36 | 37 | /// 38 | /// Gets the reason for . This property will only have a valid if the authentication 39 | /// failed and the user was redirected back to this controller. 40 | /// 41 | public string AuthErrorReason => Request.QueryString["error_reason"]; 42 | 43 | /// 44 | /// Gets the value of OAuth authentication error parameter. This property will only have a valid if the 45 | /// authentication failed and the user was redirected back to this controller. 46 | /// 47 | public string AuthError => Request.QueryString["error"]; 48 | 49 | /// 50 | /// Gets whether the OAuth authentication error parameter is present in the query string. 51 | /// 52 | public bool HasAuthError => string.IsNullOrWhiteSpace(AuthError) == false; 53 | 54 | public string AuthErrorDescription => Request.QueryString["error_description"]; 55 | 56 | public string State { 57 | get => _state ?? Request.QueryString["state"]; 58 | set => _state = value; 59 | } 60 | 61 | public bool HasState => string.IsNullOrWhiteSpace(State) == false; 62 | 63 | public MailchimpOAuthState SessionState => HasState ? Session["Skybrud.Social_" + State] as MailchimpOAuthState : null; 64 | 65 | public bool HasSessionState => SessionState != null; 66 | 67 | public string Callback => HasSessionState ? SessionState.Callback : Request.QueryString["callback"]; 68 | 69 | #endregion 70 | 71 | #region Public API methods 72 | 73 | public ActionResult Authenticate(string contentTypeAlias, string propertyAlias) { 74 | 75 | // Did we receive an error callback from Google? 76 | if (HasAuthError) { 77 | return Error("Authentication failed", "The authentication with Mailchimp failed. Close this window and try again."); 78 | } 79 | 80 | // Handle Umbraco authentication stuff 81 | HttpContextWrapper http = new HttpContextWrapper(System.Web.HttpContext.Current); 82 | AuthenticationTicket ticket = http.GetUmbracoAuthTicket(); 83 | 84 | // User must be logged in 85 | if (http.AuthenticateCurrentRequest(ticket, true) == false) { 86 | return Error("Not logged in", "You must be logged in to Umbraco to access this page. Close this window and try again."); 87 | } 88 | 89 | // Do we have a valid session? 90 | if (HasState && SessionState == null) { 91 | return Error("Session expired?", "It seems that your browser session has expired. You can try to close this window and try again."); 92 | } 93 | 94 | if (HasSessionState) { 95 | contentTypeAlias = SessionState.ContentTypeAlias; 96 | propertyAlias = SessionState.PropertyAlias; 97 | } 98 | 99 | IContentType ct = Current.Services.ContentTypeService.Get(contentTypeAlias); 100 | if (ct == null) return Error("Oooops", "Specified content type was not found."); 101 | 102 | PropertyType property = ct.PropertyTypes.FirstOrDefault(x => x.Alias == propertyAlias); 103 | if (property == null) return Error("Oooops", "Property not found."); 104 | 105 | IDataType dt = Current.Services.DataTypeService.GetDataType(property.DataTypeId); 106 | 107 | Dictionary config = dt.ConfigurationAs>(); 108 | 109 | config.TryGetValue("clientId", out object clientIdObject); 110 | config.TryGetValue("clientSecret", out object clientSecretObject); 111 | config.TryGetValue("redirectUri", out object redirectUriObject); 112 | 113 | string clientId = clientIdObject?.ToString(); 114 | string clientSecret = clientSecretObject?.ToString(); 115 | string redirectUri = redirectUriObject?.ToString(); 116 | 117 | if (string.IsNullOrWhiteSpace(clientId)) return Error("Oooops", "Invalid data type configuration."); 118 | if (string.IsNullOrWhiteSpace(clientSecret)) return Error("Oooops", "Invalid data type configuration."); 119 | if (string.IsNullOrWhiteSpace(redirectUri)) return Error("Oooops", "Invalid data type configuration."); 120 | 121 | MailchimpOAuthClient client = new MailchimpOAuthClient(clientId, clientSecret, redirectUri); 122 | 123 | // Redirect the user to the login dialog 124 | if (AuthCode == null) { 125 | 126 | // Generate a new unique/random state 127 | State = Guid.NewGuid().ToString(); 128 | 129 | // Save the state in the current user session 130 | Session["Skybrud.Social_" + State] = new MailchimpOAuthState { 131 | Callback = Callback, 132 | ContentTypeAlias = contentTypeAlias, 133 | PropertyAlias = propertyAlias 134 | }; 135 | 136 | // Construct the authorization URL 137 | string url = client.GetAuthorizationUrl(State); 138 | 139 | // Redirect the user 140 | return Redirect(url); 141 | 142 | } 143 | 144 | // Exchange the authorization code for an access token 145 | MailchimpTokenInfo info; 146 | try { 147 | info = client.GetAccessTokenFromAuthCode(AuthCode).Body; 148 | } catch (Exception ex) { 149 | Logger.Error(ex, "Unable to acquire access token."); 150 | return Error("Authentication failed", "Unable to acquire access token.", ex); 151 | } 152 | 153 | // Update the client with the access token 154 | client.AccessToken = info.AccessToken; 155 | 156 | try { 157 | 158 | // Get information about the authenticated user 159 | MailchimpMetadata meta = client.GetMetadata().Body; 160 | 161 | // Set the callback data 162 | MailchimpOAuthData data = new MailchimpOAuthData(info, meta); 163 | 164 | return View("~/App_Plugins/Skybrud.Social/Views/Mailchimp/AuthenticateSuccess.cshtml", new MailchimpAuthenticatedPageModel { 165 | Title = "Auhentication", 166 | Meta = meta, 167 | Callback = Callback, 168 | CallbackData = data 169 | }); 170 | 171 | } catch (Exception ex) { 172 | 173 | Logger.Error(ex, "Unable to get user information."); 174 | 175 | return Error("Authenticated failed", "Unable to get user information.", ex); 176 | 177 | } 178 | 179 | } 180 | 181 | private ActionResult Error(string title, string message, Exception exception = null) { 182 | return View("~/App_Plugins/Skybrud.Social/Views/AuthenticateError.cshtml", new ErrorPageModel { 183 | Title = title, 184 | Message = message, 185 | Exception = exception 186 | }); 187 | } 188 | 189 | #endregion 190 | 191 | } 192 | 193 | } -------------------------------------------------------------------------------- /src/Skybrud.Social.Umbraco/Controllers/Surface/GoogleOAuthController.cs: -------------------------------------------------------------------------------- 1 | //using System; 2 | //using System.Collections.Generic; 3 | //using System.Linq; 4 | //using System.Web; 5 | //using System.Web.Mvc; 6 | //using Microsoft.Owin.Security; 7 | //using Newtonsoft.Json.Linq; 8 | //using Skybrud.Social.Google; 9 | //using Skybrud.Social.Google.Models; 10 | //using Skybrud.Social.Google.Models.Authentication; 11 | //using Skybrud.Social.Google.OAuth; 12 | //using Skybrud.Social.Google.Scopes; 13 | //using Skybrud.Social.Umbraco.Constants; 14 | //using Skybrud.Social.Umbraco.Models.Google; 15 | //using Skybrud.Social.Umbraco.Models.Mvc; 16 | //using Umbraco.Core.Composing; 17 | //using Umbraco.Core.Logging; 18 | //using Umbraco.Core.Models; 19 | //using Umbraco.Web.Mvc; 20 | //using Umbraco.Web.Security; 21 | 22 | //namespace Skybrud.Social.Umbraco.Controllers.Surface { 23 | 24 | // [PluginController(SocialConstants.PluginController)] 25 | // public class GoogleOAuthController : SurfaceController { 26 | 27 | // private string _state; 28 | 29 | // #region Properties 30 | 31 | // /// 32 | // /// Gets the authorization code from the query string (if specified). 33 | // /// 34 | // public string AuthCode => Request.QueryString["code"]; 35 | 36 | // public string AuthState => Request.QueryString["state"]; 37 | 38 | // public string AuthErrorReason => Request.QueryString["error_reason"]; 39 | 40 | // public string AuthError => Request.QueryString["error"]; 41 | 42 | // public bool HasAuthError => String.IsNullOrWhiteSpace(AuthError) == false; 43 | 44 | // public string AuthErrorDescription => Request.QueryString["error_description"]; 45 | 46 | // public string State { 47 | // get => _state ?? Request.QueryString["state"]; 48 | // set => _state = value; 49 | // } 50 | 51 | // public bool HasState => String.IsNullOrWhiteSpace(State) == false; 52 | 53 | // public GoogleOAuthState SessionState => HasState ? Session["Skybrud.Social_" + State] as GoogleOAuthState : null; 54 | 55 | // public bool HasSessionState => SessionState != null; 56 | 57 | // public string Callback => HasSessionState ? SessionState.Callback : Request.QueryString["callback"]; 58 | 59 | // #endregion 60 | 61 | // #region Public API methods 62 | 63 | // public ActionResult Authenticate(string contentTypeAlias, string propertyAlias) { 64 | 65 | // // Did we receive an error callback from Google? 66 | // if (HasAuthError) { 67 | // return Error("Authentication failed", "The authentication with Google failed. Close this window and try again."); 68 | // } 69 | 70 | // // Handle Umbraco authentication stuff 71 | // HttpContextWrapper http = new HttpContextWrapper(System.Web.HttpContext.Current); 72 | // AuthenticationTicket ticket = http.GetUmbracoAuthTicket(); 73 | 74 | // // User must be logged in 75 | // if (http.AuthenticateCurrentRequest(ticket, true) == false) { 76 | // return Error("Not logged in", "You must be logged in to Umbraco to access this page. Close this window and try again."); 77 | // } 78 | 79 | // // Do we have a valid session? 80 | // if (HasState && SessionState == null) { 81 | // return Error("Session expired?", "It seems that your browser session has expired. You can try to close this window and try again."); 82 | // } 83 | 84 | // if (HasSessionState) { 85 | // contentTypeAlias = SessionState.ContentTypeAlias; 86 | // propertyAlias = SessionState.PropertyAlias; 87 | // } 88 | 89 | // IContentType ct = Current.Services.ContentTypeService.Get(contentTypeAlias); 90 | // if (ct == null) return Error("Oooops", "Specified content type was not found."); 91 | 92 | // PropertyType property = ct.PropertyTypes.FirstOrDefault(x => x.Alias == propertyAlias); 93 | // if (property == null) return Error("Oooops", "Property not found."); 94 | 95 | // IDataType dt = Current.Services.DataTypeService.GetDataType(property.DataTypeId); 96 | 97 | // Dictionary config = dt.ConfigurationAs>(); 98 | 99 | // config.TryGetValue("clientId", out object clientIdObject); 100 | // config.TryGetValue("clientSecret", out object clientSecretObject); 101 | // config.TryGetValue("redirectUri", out object redirectUriObject); 102 | // config.TryGetValue("scopes", out object scopes); 103 | 104 | // GoogleScopeCollection scope = new GoogleScopeCollection(); 105 | 106 | // if (scopes is JArray) { 107 | // foreach (string alias in ((JArray) scopes).Select(x => x.ToString())) { 108 | // if (GoogleUtils.TryParseScope(alias, out GoogleScope s)) scope.Add(s); 109 | // } 110 | // } 111 | 112 | // string clientId = clientIdObject?.ToString(); 113 | // string clientSecret = clientSecretObject?.ToString(); 114 | // string redirectUri = redirectUriObject?.ToString(); 115 | 116 | // if (String.IsNullOrWhiteSpace(clientId)) return Error("Oooops", "Invalid data type configuration. No client ID specified."); 117 | // if (String.IsNullOrWhiteSpace(clientSecret)) return Error("Oooops", "Invalid data type configuration. No client secret specified."); 118 | // if (String.IsNullOrWhiteSpace(redirectUri)) return Error("Oooops", "Invalid data type configuration. No redirect URI specified."); 119 | // if (scope.Items.Length == 0) return Error("Oooops", "Invalid data type configuration. One or more scopes must be selected."); 120 | 121 | // GoogleOAuthClient client = new GoogleOAuthClient(clientId, clientSecret, redirectUri); 122 | 123 | // // Redirect the user to the login dialog 124 | // if (AuthCode == null) { 125 | 126 | // // Generate a new unique/random state 127 | // State = Guid.NewGuid().ToString(); 128 | 129 | // // Save the state in the current user session 130 | // Session["Skybrud.Social_" + State] = new GoogleOAuthState { 131 | // Callback = Callback, 132 | // ContentTypeAlias = contentTypeAlias, 133 | // PropertyAlias = propertyAlias 134 | // }; 135 | 136 | // // Construct the authorization URL 137 | // string url = client.GetAuthorizationUrl(State, scope, GoogleAccessType.Offline, GoogleApprovalPrompt.Force); 138 | 139 | // // Redirect the user 140 | // return Redirect(url); 141 | 142 | // } 143 | 144 | // // Exchange the authorization code for an access token 145 | // GoogleToken info; 146 | // try { 147 | // info = client.GetAccessTokenFromAuthorizationCode(AuthCode).Body; 148 | // } catch (Exception ex) { 149 | // Logger.Error(ex, "Unable to acquire access token."); 150 | // return Error("Authentication failed", "Unable to acquire access token.", ex); 151 | // } 152 | 153 | // // Update the client with the access token 154 | // client.AccessToken = info.AccessToken; 155 | 156 | // try { 157 | 158 | // // Initialize the Google service 159 | // GoogleService service = GoogleService.CreateFromRefreshToken(client.ClientId, client.ClientSecret, info.RefreshToken); 160 | 161 | // // Get information about the authenticated user 162 | // GoogleUserInfo user = service.GetUserInfo().Body; 163 | 164 | // return View("~/App_Plugins/Skybrud.Social/Views/Google/AuthenticateSuccess.cshtml", new GoogleAuthenticatedPageModel { 165 | // Title = "Auhentication", 166 | // Callback = Callback, 167 | // CallbackData = new GoogleOAuthData(client.ClientId, client.ClientSecret, info, user) 168 | // }); 169 | 170 | // } catch (Exception ex) { 171 | 172 | // Logger.Error(ex, "Unable to get user information."); 173 | 174 | // return Error("Authenticated failed", "Unable to get user information.", ex); 175 | 176 | // } 177 | 178 | // } 179 | 180 | // private ActionResult Error(string title, string message, Exception exception = null) { 181 | // return View("~/App_Plugins/Skybrud.Social/Views/AuthenticateError.cshtml", new ErrorPageModel { 182 | // Title = title, 183 | // Message = message, 184 | // Exception = exception 185 | // }); 186 | // } 187 | 188 | // #endregion 189 | 190 | // } 191 | 192 | //} -------------------------------------------------------------------------------- /src/assemblies/Skybrud.Social.Mailchimp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Skybrud.Social.Mailchimp 5 | 6 | 7 | 8 | 9 | Class representing the lists endpoint. 10 | 11 | 12 | 13 | 14 | Gets a reference to the Mailchimp service. 15 | 16 | 17 | 18 | 19 | Gets a reference to the raw endpoint. 20 | 21 | 22 | 23 | 24 | Gets information about a specific list in your Mailchimp account. 25 | 26 | An instance of representing the response. 27 | 28 | https://developer.mailchimp.com/documentation/mailchimp/reference/lists/#read-get_lists_list_id 29 | 30 | 31 | 32 | 33 | Gets a collection of all lists of the authenticated account. 34 | 35 | An instance of representing the response. 36 | 37 | https://developer.mailchimp.com/documentation/mailchimp/reference/lists/#read-get_lists 38 | 39 | 40 | 41 | 42 | Class representing the users endpoint. 43 | 44 | 45 | 46 | 47 | Gets a reference to the Mailchimp service. 48 | 49 | 50 | 51 | 52 | Gets a reference to the raw endpoint. 53 | 54 | 55 | 56 | 57 | Gets a list of users of the account of the authenticated user. 58 | 59 | An instance of representing the response. 60 | 61 | https://apidocs.Mailchimp.com/api/2.0/users/logins.php 62 | 63 | 64 | 65 | 66 | Gets information about the authenticated user. 67 | 68 | An instance of representing the response. 69 | 70 | https://apidocs.Mailchimp.com/api/2.0/users/profile.php 71 | 72 | 73 | 74 | 75 | Class representing the raw lists endpoint. 76 | 77 | 78 | 79 | 80 | Gets a reference to the OAuth client. 81 | 82 | 83 | 84 | 85 | Gets information about a specific list in your Mailchimp account. 86 | 87 | An instance of representing the raw response. 88 | 89 | https://developer.mailchimp.com/documentation/mailchimp/reference/lists/#read-get_lists_list_id 90 | 91 | 92 | 93 | 94 | Gets a collection of all lists of the authenticated account. 95 | 96 | An instance of representing the raw response. 97 | 98 | https://developer.mailchimp.com/documentation/mailchimp/reference/lists/#read-get_lists 99 | 100 | 101 | 102 | 103 | Class representing the raw users endpoint. 104 | 105 | 106 | 107 | 108 | Gets a reference to the OAuth client. 109 | 110 | 111 | 112 | 113 | Gets a list of users of the account of the authenticated user. 114 | 115 | An instance of representing the raw response. 116 | 117 | https://apidocs.Mailchimp.com/api/2.0/users/logins.php 118 | 119 | 120 | 121 | 122 | Gets information about the authenticated user. 123 | 124 | An instance of representing the raw response. 125 | 126 | https://apidocs.Mailchimp.com/api/2.0/users/profile.php 127 | 128 | 129 | 130 | 131 | Class working as an entry point to the Mailchimp API. 132 | 133 | 134 | 135 | 136 | Gets a reference to the internal OAuth client for communication with the Mailchimp API. 137 | 138 | 139 | 140 | 141 | Gets a reference to the lists endpoint. 142 | 143 | 144 | 145 | 146 | Gets a reference to the users endpoint. 147 | 148 | 149 | 150 | 151 | Initializes a new instance from the specified OAuth . 152 | 153 | The OAuth client to be used for making requests to the Mailchimp API. 154 | A new instance of . 155 | 156 | 157 | 158 | Initializes a new instance from the specified . 159 | 160 | The API key. 161 | An instance of . 162 | 163 | 164 | 165 | Initializes a new instance from the specified and . 166 | 167 | The access token of the user. 168 | The API endpoint URL of the user. 169 | An instance of . 170 | 171 | 172 | 173 | Class representing the response body of a call to get metadata about the authenticated Mailchimp user. 174 | 175 | 176 | 177 | 178 | Gets the data center of the user/account. 179 | 180 | 181 | 182 | 183 | Gets the role of the user. 184 | 185 | 186 | 187 | 188 | Gets the name of the account. 189 | 190 | 191 | 192 | 193 | Gets the ID of the user. 194 | 195 | 196 | 197 | 198 | Gets information about the authenticated user. 199 | 200 | 201 | 202 | 203 | Gets the login URL of the account. 204 | 205 | 206 | 207 | 208 | Gets the API endpoint of the user or account. 209 | 210 | 211 | 212 | 213 | Initializes a new instance from the specified . 214 | 215 | The instance of representing the meta data. 216 | 217 | 218 | 219 | Parses the specified into an instance of . 220 | 221 | The instance of to be parsed. 222 | 223 | 224 | 225 | Class representing information about a Mailchimp user. 226 | 227 | 228 | 229 | 230 | Gets the email address of the Mailchimp user. 231 | 232 | 233 | 234 | 235 | Gets the avatar URL of the Mailchimp user. 236 | 237 | 238 | 239 | 240 | Gets the ID of the Mailchimp user. 241 | 242 | 243 | 244 | 245 | Gets the login name of the Mailchimp user. 246 | 247 | 248 | 249 | 250 | Gets the login email address of the Mailchimp user. 251 | 252 | 253 | 254 | 255 | Initializes a new instance from the specified . 256 | 257 | The instance of representing the login. 258 | 259 | 260 | 261 | Parses the specified into an instance of . 262 | 263 | The instance of to be parsed. 264 | 265 | 266 | 267 | Class representing information about an OAuth access token. 268 | 269 | 270 | 271 | 272 | Gets the access token of the authenticated user. 273 | 274 | 275 | 276 | 277 | Gets an instance of indicating when the access token will expire. According to the 278 | Mailchimp API documentation, an access token will not expire, but this property is still present in the 279 | response. The property value will most likely always be equal to . 280 | 281 | 282 | 283 | 284 | Initializes a new instance from the specified . 285 | 286 | The instance of representing the token. 287 | 288 | 289 | 290 | Parses the specified into an instance of . 291 | 292 | The instance of to be parsed. 293 | 294 | 295 | 296 | Class representing a Mailchimp mailing list. 297 | 298 | 299 | 300 | 301 | Gets the ID of the list. 302 | 303 | 304 | 305 | 306 | Gets the name of the list. 307 | 308 | 309 | 310 | 311 | Initializes a new instance from the specified . 312 | 313 | The instance of representing the list. 314 | 315 | 316 | 317 | Parses the specified into an instance of . 318 | 319 | The instance of to be parsed. 320 | 321 | 322 | 323 | Class representing a collection of Mailchimp mailing lists. 324 | 325 | 326 | 327 | 328 | Gets an array with the lists returned in the response. 329 | 330 | 331 | 332 | 333 | Gets the total number of items matching the query regardless of pagination. 334 | 335 | 336 | 337 | 338 | Initializes a new instance from the specified . 339 | 340 | The instance of representing the list. 341 | 342 | 343 | 344 | Parses the specified into an instance of . 345 | 346 | The instance of to be parsed. 347 | 348 | 349 | 350 | Class representing a basic object from the Mailchimp API derived from an instance of . 351 | 352 | 353 | 354 | 355 | Initializes a new instance from the specified . 356 | 357 | The instance of representing the object. 358 | 359 | 360 | 361 | Class representing a user of a Mailchimp account. 362 | 363 | 364 | 365 | 366 | Gets the ID of the account user. 367 | 368 | 369 | 370 | 371 | Gets the username of the Mailchimp user. 372 | 373 | 374 | 375 | 376 | Gets the name of the user. 377 | 378 | 379 | 380 | 381 | Gets the email address of the user. 382 | 383 | 384 | 385 | 386 | Gets the role of the user. 387 | 388 | 389 | 390 | 391 | Gets the avatar URL of the user. 392 | 393 | 394 | 395 | 396 | Gets the ID of the global Mailchimp user. 397 | 398 | 399 | 400 | 401 | Gets the unique ID related to the current data center. 402 | 403 | 404 | 405 | 406 | Initializes a new instance from the specified . 407 | 408 | The instance of representing the user. 409 | 410 | 411 | 412 | Parses the specified into an instance of . 413 | 414 | The instance of to be parsed. 415 | 416 | 417 | 418 | Class for handling the raw communication with the Mailchimp API as well as any OAuth 2.0 communication. 419 | 420 | 421 | 422 | 423 | Gets or sets the client ID. 424 | 425 | 426 | 427 | 428 | Gets or sets the client secret. 429 | 430 | 431 | 432 | 433 | Gets or sets the redirect URI. 434 | 435 | 436 | 437 | 438 | Gets or sets the access token. 439 | 440 | 441 | 442 | 443 | Gets or sets the API key. 444 | 445 | 446 | 447 | 448 | Gets or sets the API endpoint to be used. 449 | 450 | 451 | 452 | 453 | Gets a reference to the raw lists endpoint. 454 | 455 | 456 | 457 | 458 | Gets a reference to the raw users endpoint. 459 | 460 | 461 | 462 | 463 | Initializes an OAuth client with empty information. 464 | 465 | 466 | 467 | 468 | Initializes an OAuth client with the specified and . 469 | 470 | The ID of the client. 471 | The secret of the client. 472 | 473 | 474 | 475 | Initializes an OAuth client with the specified , and . 476 | 477 | The ID of the client. 478 | The secret of the client. 479 | The redirect URI of the client. 480 | 481 | 482 | 483 | Generates the authorization URL using the specified state. 484 | 485 | The state to send to the Mailchimp OAuth login page. 486 | An authorization URL based on . 487 | 488 | 489 | 490 | Exchanges the specified authorization code for an access token. 491 | 492 | The authorization code received from the Mailchimp OAuth dialog. 493 | An access token based on the specified . 494 | 495 | 496 | 497 | Gets metadata about the authenticated Mailchimp user. 498 | 499 | An instance of representing the response. 500 | 501 | 502 | 503 | Class representing the response of a call to get metadata about the authenticated Mailchimp user. 504 | 505 | 506 | 507 | 508 | Parses the specified into an instance of . 509 | 510 | The response to be parsed. 511 | An instance of . 512 | 513 | 514 | 515 | Class representing the OAuth 2.0 token response from the Mailchimp API. 516 | 517 | 518 | 519 | 520 | Parses the specified response into an instance of MailchimpTokenResponse. 521 | 522 | The response to be parsed. 523 | Returns an instance of MailchimpTokenResponse. 524 | 525 | 526 | 527 | Class representing a call to get information a single Mailchimp mailing list. 528 | 529 | 530 | 531 | 532 | Parses the specified into an instance of . 533 | 534 | The response to be parsed. 535 | An instance of . 536 | 537 | 538 | 539 | Class representing a call to get a collection of Mailchimp mailing lists. 540 | 541 | 542 | 543 | 544 | Parses the specified into an instance of . 545 | 546 | The response to be parsed. 547 | An instance of . 548 | 549 | 550 | 551 | Class representing a response from the Mailchimp API. 552 | 553 | 554 | 555 | 556 | Initializes a new instance based on the specified response. 557 | 558 | The raw response. 559 | 560 | 561 | 562 | Validates the specified response. 563 | 564 | The response to be validated. 565 | 566 | 567 | 568 | Class representing a response from the Mailchimp API. 569 | 570 | 571 | 572 | 573 | Gets the body of the response. 574 | 575 | 576 | 577 | 578 | Initializes a new instance based on the specified response. 579 | 580 | The raw response. 581 | 582 | 583 | 584 | Class representing a call to get information a single account user. 585 | 586 | 587 | 588 | 589 | Parses the specified response into an instance of MailchimpGetUserResponse. 590 | 591 | The response to be parsed. 592 | Returns an instance of MailchimpGetUserResponse. 593 | 594 | 595 | 596 | Class representing a call to get a list of users of an account. 597 | 598 | 599 | 600 | 601 | Parses the specified response into an instance of MailchimpGetUsersResponse. 602 | 603 | The response to be parsed. 604 | Returns an instance of MailchimpGetUsersResponse. 605 | 606 | 607 | 608 | --------------------------------------------------------------------------------