diff --git a/AspNet.Security.OAuth.Providers.sln b/AspNet.Security.OAuth.Providers.sln index e5b64b67c..b6d50e601 100644 --- a/AspNet.Security.OAuth.Providers.sln +++ b/AspNet.Security.OAuth.Providers.sln @@ -220,6 +220,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{C2CA4B38-A docs\xumm.md = docs\xumm.md docs\zendesk.md = docs\zendesk.md docs\docusign.md = docs\docusign.md + docs\gitcode.md = docs\gitcode.md EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.Basecamp", "src\AspNet.Security.OAuth.Basecamp\AspNet.Security.OAuth.Basecamp.csproj", "{42306484-B2BF-4B52-B950-E0CDFA58B02A}" @@ -313,6 +314,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Security.OAuth.Zoho" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Security.OAuth.VkId", "src\AspNet.Security.OAuth.VkId\AspNet.Security.OAuth.VkId.csproj", "{F3E62C24-5F82-4CF5-A994-0E10D04FB495}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Security.OAuth.GitCode", "src\AspNet.Security.OAuth.GitCode\AspNet.Security.OAuth.GitCode.csproj", "{668833D5-DB6A-475F-B0FD-A03462B037B8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -727,6 +730,10 @@ Global {F3E62C24-5F82-4CF5-A994-0E10D04FB495}.Debug|Any CPU.Build.0 = Debug|Any CPU {F3E62C24-5F82-4CF5-A994-0E10D04FB495}.Release|Any CPU.ActiveCfg = Release|Any CPU {F3E62C24-5F82-4CF5-A994-0E10D04FB495}.Release|Any CPU.Build.0 = Release|Any CPU + {668833D5-DB6A-475F-B0FD-A03462B037B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {668833D5-DB6A-475F-B0FD-A03462B037B8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {668833D5-DB6A-475F-B0FD-A03462B037B8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {668833D5-DB6A-475F-B0FD-A03462B037B8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -840,6 +847,7 @@ Global {4E96BD06-04CD-4014-BA42-10D2CDB820D6} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D} {CD56ABE4-1CD2-4029-B556-E110A31A2CC4} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D} {F3E62C24-5F82-4CF5-A994-0E10D04FB495} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D} + {668833D5-DB6A-475F-B0FD-A03462B037B8} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C7B54DE2-6407-4802-AD9C-CE54BF414C8C} diff --git a/README.md b/README.md index 943168778..279718821 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,7 @@ If a provider you're looking for does not exist, consider making a PR to add one | Feishu | [![NuGet](https://img.shields.io/nuget/v/AspNet.Security.OAuth.Feishu?logo=nuget&label=NuGet&color=blue)](https://www.nuget.org/packages/AspNet.Security.OAuth.Feishu/ "Download AspNet.Security.OAuth.Feishu from NuGet.org") | [![MyGet](https://img.shields.io/myget/aspnet-contrib/vpre/AspNet.Security.OAuth.Feishu?logo=nuget&label=MyGet&color=blue)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Feishu "Download AspNet.Security.OAuth.Feishu from MyGet.org") | [Documentation](https://open.feishu.cn/document/common-capabilities/sso/web-application-sso/web-app-overview "Feishu developer documentation") | | Fitbit | [![NuGet](https://img.shields.io/nuget/v/AspNet.Security.OAuth.Fitbit?logo=nuget&label=NuGet&color=blue)](https://www.nuget.org/packages/AspNet.Security.OAuth.Fitbit/ "Download AspNet.Security.OAuth.Fitbit from NuGet.org") | [![MyGet](https://img.shields.io/myget/aspnet-contrib/vpre/AspNet.Security.OAuth.Fitbit?logo=nuget&label=MyGet&color=blue)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Fitbit "Download AspNet.Security.OAuth.Fitbit from MyGet.org") | [Documentation](https://dev.fitbit.com/build/reference/web-api/oauth2/ "Fitbit developer documentation") | | Foursquare | [![NuGet](https://img.shields.io/nuget/v/AspNet.Security.OAuth.Foursquare?logo=nuget&label=NuGet&color=blue)](https://www.nuget.org/packages/AspNet.Security.OAuth.Foursquare/ "Download AspNet.Security.OAuth.Foursquare from NuGet.org") | [![MyGet](https://img.shields.io/myget/aspnet-contrib/vpre/AspNet.Security.OAuth.Foursquare?logo=nuget&label=MyGet&color=blue)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Foursquare "Download AspNet.Security.OAuth.Foursquare from MyGet.org") | [Documentation](https://developer.foursquare.com/docs/api/configuration/authentication "Foursquare developer documentation") | +| GitCode | [![NuGet](https://img.shields.io/nuget/v/AspNet.Security.OAuth.GitCode?logo=nuget&label=NuGet&color=blue)](https://www.nuget.org/packages/AspNet.Security.OAuth.GitCode/ "Download AspNet.Security.OAuth.GitCode from NuGet.org") | [![MyGet](https://img.shields.io/myget/aspnet-contrib/vpre/AspNet.Security.OAuth.GitCode?logo=nuget&label=MyGet&color=blue)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.GitCode "Download AspNet.Security.OAuth.GitCode from MyGet.org") | [Documentation](https://docs.gitcode.com/en/docs/oauth/ "GitCode developer documentation") | | Gitee | [![NuGet](https://img.shields.io/nuget/v/AspNet.Security.OAuth.Gitee?logo=nuget&label=NuGet&color=blue)](https://www.nuget.org/packages/AspNet.Security.OAuth.Gitee/ "Download AspNet.Security.OAuth.Gitee from NuGet.org") | [![MyGet](https://img.shields.io/myget/aspnet-contrib/vpre/AspNet.Security.OAuth.Gitee?logo=nuget&label=MyGet&color=blue)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Gitee "Download AspNet.Security.OAuth.Gitee from MyGet.org") | [Documentation](https://gitee.com/api/v5/oauth_doc#/ "Gitee developer documentation") | | GitHub | [![NuGet](https://img.shields.io/nuget/v/AspNet.Security.OAuth.GitHub?logo=nuget&label=NuGet&color=blue)](https://www.nuget.org/packages/AspNet.Security.OAuth.GitHub/ "Download AspNet.Security.OAuth.GitHub from NuGet.org") | [![MyGet](https://img.shields.io/myget/aspnet-contrib/vpre/AspNet.Security.OAuth.GitHub?logo=nuget&label=MyGet&color=blue)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.GitHub "Download AspNet.Security.OAuth.GitHub from MyGet.org") | [Documentation](https://developer.github.com/apps/building-oauth-apps/ "GitHub developer documentation") | | GitLab | [![NuGet](https://img.shields.io/nuget/v/AspNet.Security.OAuth.GitLab?logo=nuget&label=NuGet&color=blue)](https://www.nuget.org/packages/AspNet.Security.OAuth.GitLab/ "Download AspNet.Security.OAuth.GitLab from NuGet.org") | [![MyGet](https://img.shields.io/myget/aspnet-contrib/vpre/AspNet.Security.OAuth.GitLab?logo=nuget&label=MyGet&color=blue)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.GitLab "Download AspNet.Security.OAuth.GitLab from MyGet.org") | [Documentation](https://docs.gitlab.com/ee/api/oauth2.html "GitLab developer documentation") | diff --git a/docs/README.md b/docs/README.md index a05f40a7b..5a25cacdb 100644 --- a/docs/README.md +++ b/docs/README.md @@ -52,6 +52,7 @@ covered by the section above. | eBay | **Required** | [Documentation](ebay.md "eBay provider documentation") | | EVEOnline | _Optional_ | [Documentation](eveonline.md "EVEOnline provider documentation") | | Foursquare | _Optional_ | [Documentation](foursquare.md "Foursquare provider documentation") | +| GitCode | _Optional_ | [Documentation](gitcode.md "GitCode provider documentation") | | GitHub | _Optional_ | [Documentation](github.md "GitHub provider documentation") | | Gitee | _Optional_ | [Documentation](gitee.md "Gitee provider documentation") | | Huawei | _Optional_ | [Documentation](huawei.md "Huawei provider documentation") | diff --git a/docs/gitcode.md b/docs/gitcode.md new file mode 100644 index 000000000..3ec343819 --- /dev/null +++ b/docs/gitcode.md @@ -0,0 +1,24 @@ +# Integrating the GitCode Provider + +## Example + +```csharp +services.AddAuthentication(options => /* Auth configuration */) + .AddGitCode(options => + { + options.ClientId = "my-client-id"; + options.ClientSecret = "my-client-secret"; + + // GitCode does not support setting scopes via requests to the API. + // The configuration of scopes (App permissions) are instead managed + // within the OAuth app management in GitCode itself. + }); +``` + +## Required Additional Settings + +_None._ + +## Optional Settings + +_None._ diff --git a/eng/Versions.props b/eng/Versions.props index 39dcb91a5..0b8e81be7 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -2,7 +2,7 @@ 9 - 0 + 1 0 $(MajorVersion).$(MinorVersion).$(PatchVersion) 9.0.0 diff --git a/src/AspNet.Security.OAuth.GitCode/AspNet.Security.OAuth.GitCode.csproj b/src/AspNet.Security.OAuth.GitCode/AspNet.Security.OAuth.GitCode.csproj new file mode 100644 index 000000000..f5e3a122f --- /dev/null +++ b/src/AspNet.Security.OAuth.GitCode/AspNet.Security.OAuth.GitCode.csproj @@ -0,0 +1,24 @@ + + + + 9.1.0 + $(DefaultNetCoreTargetFramework) + + + + + true + + + + ASP.NET Core security middleware enabling GitCode authentication. + Gehongyan + aspnetcore;authentication;gitcode;oauth;security + + + + + + + + diff --git a/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationConstants.cs b/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationConstants.cs new file mode 100644 index 000000000..a0d1e11bf --- /dev/null +++ b/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationConstants.cs @@ -0,0 +1,23 @@ +/* + * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) + * See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers + * for more information concerning the license and the contributors participating to this project. + */ + +namespace AspNet.Security.OAuth.GitCode; + +/// +/// Contains constants specific to the . +/// +public static class GitCodeAuthenticationConstants +{ + public static class Claims + { + public const string AvatarUrl = "urn:gitcode:avatar_url"; + public const string Bio = "urn:gitcode:bio"; + public const string Blog = "urn:gitcode:blog"; + public const string Company = "urn:gitcode:company"; + public const string HtmlUrl = "urn:gitcode:html_url"; + public const string Name = "urn:gitcode:name"; + } +} diff --git a/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationDefaults.cs b/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationDefaults.cs new file mode 100644 index 000000000..4aa5d2a7b --- /dev/null +++ b/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationDefaults.cs @@ -0,0 +1,48 @@ +/* + * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) + * See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers + * for more information concerning the license and the contributors participating to this project. + */ + +namespace AspNet.Security.OAuth.GitCode; + +/// +/// Default values used by the GitCode authentication middleware. +/// +public static class GitCodeAuthenticationDefaults +{ + /// + /// Default value for . + /// + public const string AuthenticationScheme = "GitCode"; + + /// + /// Default value for . + /// + public static readonly string DisplayName = "GitCode"; + + /// + /// Default value for . + /// + public static readonly string Issuer = "GitCode"; + + /// + /// Default value for . + /// + public static readonly string CallbackPath = "/signin-gitcode"; + + /// + /// Default value for . + /// + public static readonly string AuthorizationEndpoint = "https://gitcode.com/oauth/authorize"; + + /// + /// Default value for . + /// + public static readonly string TokenEndpoint = "https://gitcode.com/oauth/token"; + + /// + /// Default value for . + /// + public static readonly string UserInformationEndpoint = "https://api.gitcode.com/api/v5/user"; +} diff --git a/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationExtensions.cs b/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationExtensions.cs new file mode 100644 index 000000000..4f136c48e --- /dev/null +++ b/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationExtensions.cs @@ -0,0 +1,74 @@ +/* + * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) + * See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers + * for more information concerning the license and the contributors participating to this project. + */ + +using AspNet.Security.OAuth.GitCode; + +namespace Microsoft.Extensions.DependencyInjection; + +/// +/// Extension methods to add GitCode authentication capabilities to an HTTP application pipeline. +/// +public static class GitCodeAuthenticationExtensions +{ + /// + /// Adds to the specified + /// , which enables GitCode authentication capabilities. + /// + /// The authentication builder. + /// The . + public static AuthenticationBuilder AddGitCode([NotNull] this AuthenticationBuilder builder) + { + return builder.AddGitCode(GitCodeAuthenticationDefaults.AuthenticationScheme, options => { }); + } + + /// + /// Adds to the specified + /// , which enables GitCode authentication capabilities. + /// + /// The authentication builder. + /// The delegate used to configure the OpenID 2.0 options. + /// The . + public static AuthenticationBuilder AddGitCode( + [NotNull] this AuthenticationBuilder builder, + [NotNull] Action configuration) + { + return builder.AddGitCode(GitCodeAuthenticationDefaults.AuthenticationScheme, configuration); + } + + /// + /// Adds to the specified + /// , which enables GitCode authentication capabilities. + /// + /// The authentication builder. + /// The authentication scheme associated with this instance. + /// The delegate used to configure the GitCode options. + /// The . + public static AuthenticationBuilder AddGitCode( + [NotNull] this AuthenticationBuilder builder, + [NotNull] string scheme, + [NotNull] Action configuration) + { + return builder.AddGitCode(scheme, GitCodeAuthenticationDefaults.DisplayName, configuration); + } + + /// + /// Adds to the specified + /// , which enables GitCode authentication capabilities. + /// + /// The authentication builder. + /// The authentication scheme associated with this instance. + /// The optional display name associated with this instance. + /// The delegate used to configure the GitCode options. + /// The . + public static AuthenticationBuilder AddGitCode( + [NotNull] this AuthenticationBuilder builder, + [NotNull] string scheme, + [CanBeNull] string caption, + [NotNull] Action configuration) + { + return builder.AddOAuth(scheme, caption, configuration); + } +} diff --git a/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationHandler.cs b/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationHandler.cs new file mode 100644 index 000000000..a866a32dd --- /dev/null +++ b/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationHandler.cs @@ -0,0 +1,72 @@ +/* + * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) + * See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers + * for more information concerning the license and the contributors participating to this project. + */ + +using System.Net; +using System.Net.Http.Headers; +using System.Net.Mime; +using System.Security.Claims; +using System.Text.Encodings.Web; +using System.Text.Json; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace AspNet.Security.OAuth.GitCode; + +public partial class GitCodeAuthenticationHandler : OAuthHandler +{ + public GitCodeAuthenticationHandler( + [NotNull] IOptionsMonitor options, + [NotNull] ILoggerFactory logger, + [NotNull] UrlEncoder encoder) + : base(options, logger, encoder) + { + } + + protected override async Task CreateTicketAsync( + [NotNull] ClaimsIdentity identity, + [NotNull] AuthenticationProperties properties, + [NotNull] OAuthTokenResponse tokens) + { + using var request = new HttpRequestMessage(HttpMethod.Get, Options.UserInformationEndpoint); + request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(MediaTypeNames.Application.Json)); + request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", tokens.AccessToken); + + using var response = await Backchannel.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, Context.RequestAborted); + if (!response.IsSuccessStatusCode) + { + await Log.UserProfileErrorAsync(Logger, response, Context.RequestAborted); + throw new HttpRequestException("An error occurred while retrieving the user profile."); + } + + using var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync(Context.RequestAborted)); + + var principal = new ClaimsPrincipal(identity); + var context = new OAuthCreatingTicketContext(principal, properties, Context, Scheme, Options, Backchannel, tokens, payload.RootElement); + context.RunClaimActions(); + + await Events.CreatingTicket(context); + return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name); + } + + private static partial class Log + { + internal static async Task UserProfileErrorAsync(ILogger logger, HttpResponseMessage response, CancellationToken cancellationToken) + { + UserProfileError( + logger, + response.StatusCode, + response.Headers.ToString(), + await response.Content.ReadAsStringAsync(cancellationToken)); + } + + [LoggerMessage(1, LogLevel.Error, "An error occurred while retrieving the user profile: the remote server returned a {Status} response with the following payload: {Headers} {Body}.")] + private static partial void UserProfileError( + ILogger logger, + HttpStatusCode status, + string headers, + string body); + } +} diff --git a/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationOptions.cs b/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationOptions.cs new file mode 100644 index 000000000..0854367da --- /dev/null +++ b/src/AspNet.Security.OAuth.GitCode/GitCodeAuthenticationOptions.cs @@ -0,0 +1,36 @@ +/* + * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) + * See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers + * for more information concerning the license and the contributors participating to this project. + */ + +using System.Security.Claims; +using static AspNet.Security.OAuth.GitCode.GitCodeAuthenticationConstants; + +namespace AspNet.Security.OAuth.GitCode; + +/// +/// Defines a set of options used by . +/// +public class GitCodeAuthenticationOptions : OAuthOptions +{ + public GitCodeAuthenticationOptions() + { + ClaimsIssuer = GitCodeAuthenticationDefaults.Issuer; + CallbackPath = GitCodeAuthenticationDefaults.CallbackPath; + + AuthorizationEndpoint = GitCodeAuthenticationDefaults.AuthorizationEndpoint; + TokenEndpoint = GitCodeAuthenticationDefaults.TokenEndpoint; + UserInformationEndpoint = GitCodeAuthenticationDefaults.UserInformationEndpoint; + + ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); + ClaimActions.MapJsonKey(ClaimTypes.Name, "login"); + ClaimActions.MapJsonKey(ClaimTypes.Email, "email"); + ClaimActions.MapJsonKey(Claims.AvatarUrl, "avatar_url"); + ClaimActions.MapJsonKey(Claims.Bio, "bio"); + ClaimActions.MapJsonKey(Claims.Blog, "blog"); + ClaimActions.MapJsonKey(Claims.Company, "company"); + ClaimActions.MapJsonKey(Claims.HtmlUrl, "html_url"); + ClaimActions.MapJsonKey(Claims.Name, "name"); + } +} diff --git a/test/AspNet.Security.OAuth.Providers.Tests/GitCode/GitCodeTests.cs b/test/AspNet.Security.OAuth.Providers.Tests/GitCode/GitCodeTests.cs new file mode 100644 index 000000000..299e10e57 --- /dev/null +++ b/test/AspNet.Security.OAuth.Providers.Tests/GitCode/GitCodeTests.cs @@ -0,0 +1,30 @@ +/* + * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) + * See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers + * for more information concerning the license and the contributors participating to this project. + */ + +namespace AspNet.Security.OAuth.GitCode; + +public class GitCodeTests(ITestOutputHelper outputHelper) : OAuthTests(outputHelper) +{ + public override string DefaultScheme => GitCodeAuthenticationDefaults.AuthenticationScheme; + + protected internal override void RegisterAuthentication(AuthenticationBuilder builder) + { + builder.AddGitCode(options => ConfigureDefaults(builder, options)); + } + + [Theory] + [InlineData(ClaimTypes.NameIdentifier, "example-id")] + [InlineData(ClaimTypes.Name, "example-login")] + [InlineData(ClaimTypes.Email, "example@example.com")] + [InlineData("urn:gitcode:avatar_url", "https://cdn-img.gitcode.com/fa/be/example.png?time=1694709764757")] + [InlineData("urn:gitcode:bio", "Example bio")] + [InlineData("urn:gitcode:blog", "https://gitcode.com")] + [InlineData("urn:gitcode:company", "Example company")] + [InlineData("urn:gitcode:html_url", "https://gitcode.com/example")] + [InlineData("urn:gitcode:name", "example-name")] + public async Task Can_Sign_In_Using_GitCode(string claimType, string claimValue) + => await AuthenticateUserAndAssertClaimValue(claimType, claimValue); +} diff --git a/test/AspNet.Security.OAuth.Providers.Tests/GitCode/bundle.json b/test/AspNet.Security.OAuth.Providers.Tests/GitCode/bundle.json new file mode 100644 index 000000000..7b11327c4 --- /dev/null +++ b/test/AspNet.Security.OAuth.Providers.Tests/GitCode/bundle.json @@ -0,0 +1,45 @@ +{ + "$schema": "https://raw.githubusercontent.com/justeat/httpclient-interception/master/src/HttpClientInterception/Bundles/http-request-bundle-schema.json", + "items": [ + { + "uri": "https://gitcode.com/oauth/token", + "method": "POST", + "contentFormat": "json", + "contentJson": { + "access_token": "secret-access-token", + "expires_in": 1296000, + "refresh_token": "secret-refresh-token", + "scope": "all_user all_key all_groups all_projects all_pr all_issue all_note all_hook all_repository", + "created_at": "2024-04-20T09:07:59.889Z" + } + }, + { + "comment": "https://docs.gitcode.com/en/docs/apis/get-api-v-5-user/", + "uri": "https://api.gitcode.com/api/v5/user", + "contentFormat": "json", + "contentJson": { + "avatar_url": "https://cdn-img.gitcode.com/fa/be/example.png?time=1694709764757", + "followers_url": "https://api.gitcode.com/api/v5/users/example/followers", + "html_url": "https://gitcode.com/example", + "id": "example-id", + "login": "example-login", + "name": "example-name", + "type": "User", + "url": "https://api.gitcode.com/api/v5/example", + "bio": "Example bio", + "blog": "https://gitcode.com", + "company": "Example company", + "email": "example@example.com", + "followers": 8, + "following": 35, + "top_languages": [ + "Python", + "Markdown", + "C++", + "C", + "HTML" + ] + } + } + ] +}