Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 2c21b65

Browse files
authored
Merge branch 'master' into fixes/usage-service-initialization
2 parents 28dd2f3 + 97e4570 commit 2c21b65

File tree

86 files changed

+2739
-786
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2739
-786
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
url = https://github.com/editor-tools/Akavache
1313
[submodule "script"]
1414
path = script
15-
url = [email protected]:github/VisualStudioBuildScripts
15+
url = [email protected]:github/VisualStudioBuildScripts

lib/Rothko.0.0.2-ghfvs.nupkg

-33.9 KB
Binary file not shown.

lib/Rothko.0.0.3-ghfvs.nupkg

40.7 KB
Binary file not shown.

src/GitHub.Api/ApiClientConfiguration.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Globalization;
34
using System.Linq;
45
using System.Net;
56
using System.Net.NetworkInformation;
6-
using System.Reflection;
77
using System.Security.Cryptography;
88
using System.Text;
9-
using GitHub.Primitives;
109

1110
namespace GitHub.Api
1211
{
@@ -33,6 +32,11 @@ static ApiClientConfiguration()
3332
/// </summary>
3433
public static string ClientSecret { get; private set; }
3534

35+
/// <summary>
36+
/// Gets the scopes required by the application.
37+
/// </summary>
38+
public static IReadOnlyList<string> RequiredScopes { get; } = new[] { "user", "repo", "gist", "write:public_key" };
39+
3640
/// <summary>
3741
/// Gets a note that will be stored with the OAUTH token.
3842
/// </summary>

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
</PropertyGroup>
4747
<Import Project="$(SolutionDir)\src\common\signing.props" />
4848
<ItemGroup>
49+
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
50+
<HintPath>..\..\packages\Serilog.2.5.0\lib\net46\Serilog.dll</HintPath>
51+
<Private>True</Private>
52+
</Reference>
4953
<Reference Include="System" />
5054
<Reference Include="System.ComponentModel.Composition" />
5155
<Reference Include="System.Core" />
@@ -64,6 +68,8 @@
6468
<Compile Include="ApiClientConfiguration_User.cs" Condition="$(Buildtype) != 'Internal'" />
6569
<Compile Include="IKeychain.cs" />
6670
<Compile Include="ILoginManager.cs" />
71+
<Compile Include="IOAuthCallbackListener.cs" />
72+
<Compile Include="IncorrectScopesException.cs" />
6773
<Compile Include="ITwoFactorChallengeHandler.cs" />
6874
<Compile Include="LoginManager.cs" />
6975
<Compile Include="KeychainCredentialStore.cs" />
@@ -99,6 +105,9 @@
99105
<Name>GitHub.Logging</Name>
100106
</ProjectReference>
101107
</ItemGroup>
108+
<ItemGroup>
109+
<None Include="packages.config" />
110+
</ItemGroup>
102111
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
103112
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
104113
Other similar extension points exist, see Microsoft.Common.targets.

src/GitHub.Api/ILoginManager.cs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Runtime.InteropServices;
1+
using System;
2+
using System.Runtime.InteropServices;
3+
using System.Threading;
24
using System.Threading.Tasks;
35
using GitHub.Primitives;
46
using GitHub.VisualStudio;
@@ -25,6 +27,36 @@ public interface ILoginManager
2527
/// </exception>
2628
Task<User> Login(HostAddress hostAddress, IGitHubClient client, string userName, string password);
2729

30+
/// <summary>
31+
/// Attempts to log into a GitHub server via OAuth in the browser.
32+
/// </summary>
33+
/// <param name="hostAddress">The address of the server.</param>
34+
/// <param name="client">An octokit client configured to access the server.</param>
35+
/// <param name="oauthClient">An octokit OAuth client configured to access the server.</param>
36+
/// <param name="openBrowser">A callback that should open a browser at the requested URL.</param>
37+
/// <param name="cancel">A cancellation token used to cancel the operation.</param>
38+
/// <returns>The logged in user.</returns>
39+
/// <exception cref="AuthorizationException">
40+
/// The login authorization failed.
41+
/// </exception>
42+
Task<User> LoginViaOAuth(
43+
HostAddress hostAddress,
44+
IGitHubClient client,
45+
IOauthClient oauthClient,
46+
Action<Uri> openBrowser,
47+
CancellationToken cancel);
48+
49+
/// <summary>
50+
/// Attempts to log into a GitHub server with a token.
51+
/// </summary>
52+
/// <param name="hostAddress">The address of the server.</param>
53+
/// <param name="client">An octokit client configured to access the server.</param>
54+
/// <param name="token">The token.</param>
55+
Task<User> LoginWithToken(
56+
HostAddress hostAddress,
57+
IGitHubClient client,
58+
string token);
59+
2860
/// <summary>
2961
/// Attempts to log into a GitHub server using existing credentials.
3062
/// </summary>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
5+
namespace GitHub.Api
6+
{
7+
/// <summary>
8+
/// Listens for a callback from the OAuth endpoint signalling successful login.
9+
/// </summary>
10+
public interface IOAuthCallbackListener
11+
{
12+
/// <summary>
13+
/// Listens for a callback with a `state` matching <paramref name="id"/>.
14+
/// </summary>
15+
/// <param name="id">The ID of the operation.</param>
16+
/// <param name="cancel">A cancellation token.</param>
17+
/// <returns>The temporary code included in the callback.</returns>
18+
Task<string> Listen(string id, CancellationToken cancel);
19+
}
20+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Runtime.Serialization;
3+
4+
namespace GitHub.Api
5+
{
6+
/// <summary>
7+
/// Thrown when the login for a user does not have the required API scopes.
8+
/// </summary>
9+
[Serializable]
10+
public class IncorrectScopesException : Exception
11+
{
12+
public IncorrectScopesException()
13+
: this("Incorrect API scopes.")
14+
{
15+
}
16+
17+
public IncorrectScopesException(string message)
18+
: base(message)
19+
{
20+
}
21+
22+
public IncorrectScopesException(string message, Exception innerException)
23+
: base(message, innerException)
24+
{
25+
}
26+
27+
protected IncorrectScopesException(SerializationInfo info, StreamingContext context)
28+
: base(info, context)
29+
{
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)