Skip to content

Commit

Permalink
Fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
a32kita committed Aug 24, 2020
1 parent 53d8d15 commit dc485aa
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 6 deletions.
25 changes: 25 additions & 0 deletions src/Swarm.NET/Endpoints/ApiBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace SwarmDotNET.Endpoints
{
public abstract class ApiBase
{
// 限定公開プロパティ

protected SwarmService ParentService
{
get;
private set;
}


// コンストラクタ

public ApiBase(SwarmService parentService)
{
this.ParentService = parentService;
}
}
}
15 changes: 15 additions & 0 deletions src/Swarm.NET/Endpoints/VenuesApi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace SwarmDotNET.Endpoints
{
public class VenuesApi : ApiBase
{
public VenuesApi(SwarmService parentService)
: base(parentService)
{

}
}
}
2 changes: 2 additions & 0 deletions src/Swarm.NET/Swarm.NET.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<Import_RootNamespace>SwarmDotNET</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Endpoints\ApiBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Endpoints\VenuesApi.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Entities\UserAccessToken.cs" />
<Compile Include="$(MSBuildThisFileDirectory)InternalUtilities\UriUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SwarmClientInfo.cs" />
Expand Down
6 changes: 6 additions & 0 deletions src/Swarm.NET/SwarmService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;

using Newtonsoft.Json;
using Newtonsoft.Json.Bson;
using SwarmDotNET.Entities;
using SwarmDotNET.InternalUtilities;

Expand Down Expand Up @@ -88,6 +89,11 @@ public async Task AuthorizeWithCodeAsync(string code)
}
}

public void AuthorizeWithUserAccessToken(UserAccessToken accessToken)
{
this.AccessToken = accessToken;
}

public void Dispose()
{
this._httpClient.Dispose();
Expand Down
26 changes: 20 additions & 6 deletions src/Tests/Swarm.NET.Demo/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Management.Instrumentation;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -11,18 +13,30 @@ class Program
{
static void Main(string[] args)
{
using (var swService = new SwarmService(new SwarmClientInfo()
var datFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Swarm.NET.dat");

if (File.Exists(datFilePath) == false)
{
ClientId = "KWCZOZ5S5WGXNE054WLHNWZ0BJNRMHRS5FOCZASF15JRPQUP",
ClientSecret = "1I1CGA0UTKS2T0WFWPZR5YNN0QHFY3M2XSKFWS5RA34XNCXN",
AuthorizationRedirectUri = new Uri("http://www.a32kita.net/dummy/fsqauth"),
}))
Console.WriteLine("Please put client info file.");
Console.WriteLine(datFilePath);
Environment.Exit(1);
}

var clientInfo = new SwarmClientInfo();
using (var sr = new StreamReader(File.OpenRead(datFilePath)))
{
clientInfo.ClientId = sr.ReadLine();
clientInfo.ClientSecret = sr.ReadLine();
clientInfo.AuthorizationRedirectUri = new Uri(sr.ReadLine());
}

using (var swService = new SwarmService(clientInfo))
{
Console.WriteLine("Please authorize this client;");
Console.WriteLine(swService.GetAuthorizationUri());
Console.WriteLine();
Console.WriteLine("Please input redirected uri;");

Console.Write("> ");
var redirectedUri = Console.ReadLine();

Expand Down

0 comments on commit dc485aa

Please sign in to comment.