diff --git a/GmailArneMoermanSorter.sln b/GmailArneMoermanSorter.sln new file mode 100644 index 0000000..bd4bc41 --- /dev/null +++ b/GmailArneMoermanSorter.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34221.43 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GmailArneMoermanSorter", "GmailArneMoermanSorter\GmailArneMoermanSorter.csproj", "{3ECD0085-DC1D-429C-87D2-E3FEBC12BBC9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3ECD0085-DC1D-429C-87D2-E3FEBC12BBC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3ECD0085-DC1D-429C-87D2-E3FEBC12BBC9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3ECD0085-DC1D-429C-87D2-E3FEBC12BBC9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3ECD0085-DC1D-429C-87D2-E3FEBC12BBC9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {35572BF2-9ACB-45E6-8671-ADC9D1D25CC1} + EndGlobalSection +EndGlobal diff --git a/GmailArneMoermanSorter/GmailArneMoermanSorter.csproj b/GmailArneMoermanSorter/GmailArneMoermanSorter.csproj new file mode 100644 index 0000000..f838547 --- /dev/null +++ b/GmailArneMoermanSorter/GmailArneMoermanSorter.csproj @@ -0,0 +1,20 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + + + Always + + + + diff --git a/GmailArneMoermanSorter/Program.cs b/GmailArneMoermanSorter/Program.cs new file mode 100644 index 0000000..32251da --- /dev/null +++ b/GmailArneMoermanSorter/Program.cs @@ -0,0 +1,48 @@ +using Google.Apis.Auth.OAuth2; +using Google.Apis.Gmail.v1; +using Google.Apis.Services; +using Google.Apis.Util.Store; + +namespace GmailArneMoermanSorter +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("Access emails over Gmail Api"); + try + { + new Program().Run().Wait(); + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } + + private async Task Run() + { + UserCredential credential; + using (var stream = new FileStream("clientSecret.json", FileMode.Open, FileAccess.Read)) + { + credential = await GoogleWebAuthorizationBroker.AuthorizeAsync( + GoogleClientSecrets.FromStream(stream).Secrets, + new[] {GmailService.Scope.GmailLabels}, + "user", CancellationToken.None, new FileDataStore("GmailApi.Auth.Store")); + } + + var service = new GmailService(new BaseClientService.Initializer() + { + HttpClientInitializer = credential, + ApplicationName = "GmailArneMoermanSorter" + }); + + var labels = await service.Users.Labels.List("me").ExecuteAsync(); + foreach (var label in labels.Labels) + { + Console.WriteLine(label.Name); + } + } + } +} \ No newline at end of file diff --git a/GmailArneMoermanSorter/clientSecret.json b/GmailArneMoermanSorter/clientSecret.json new file mode 100644 index 0000000..0db3279 --- /dev/null +++ b/GmailArneMoermanSorter/clientSecret.json @@ -0,0 +1,3 @@ +{ + +} diff --git a/GmailArneMoermanSorter/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs b/GmailArneMoermanSorter/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs new file mode 100644 index 0000000..4257f4b --- /dev/null +++ b/GmailArneMoermanSorter/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")] diff --git a/GmailArneMoermanSorter/obj/Debug/net7.0/GmailArneMoermanSorter.AssemblyInfo.cs b/GmailArneMoermanSorter/obj/Debug/net7.0/GmailArneMoermanSorter.AssemblyInfo.cs new file mode 100644 index 0000000..02f7c77 --- /dev/null +++ b/GmailArneMoermanSorter/obj/Debug/net7.0/GmailArneMoermanSorter.AssemblyInfo.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("GmailArneMoermanSorter")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] +[assembly: System.Reflection.AssemblyProductAttribute("GmailArneMoermanSorter")] +[assembly: System.Reflection.AssemblyTitleAttribute("GmailArneMoermanSorter")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/GmailArneMoermanSorter/obj/Debug/net7.0/GmailArneMoermanSorter.GlobalUsings.g.cs b/GmailArneMoermanSorter/obj/Debug/net7.0/GmailArneMoermanSorter.GlobalUsings.g.cs new file mode 100644 index 0000000..8578f3d --- /dev/null +++ b/GmailArneMoermanSorter/obj/Debug/net7.0/GmailArneMoermanSorter.GlobalUsings.g.cs @@ -0,0 +1,8 @@ +// +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Threading; +global using global::System.Threading.Tasks;