Skip to content

Commit 8f1d875

Browse files
committed
Update 0.3.2
1 parent 1c85170 commit 8f1d875

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

GoogleApis.Blazor/Auth/AuthService.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,25 @@ public AuthService(IJSRuntime jsRuntime, IHttpClientFactory httpClientFactory, I
4141
/// <returns></returns>
4242
public async Task RequestAuthorizationCode(string clientId, List<Scope> scopes, string redirectUrl, PromptType promptType = PromptType.Consent)
4343
{
44-
string encodedRedirectUrl = HttpUtility.UrlEncode(redirectUrl);
4544
if (scopes == null || scopes.Count == 0)
4645
{
4746
return;
4847
}
49-
List<string> scopeStringList = new List<string>();
50-
foreach (var scope in scopes)
51-
{
52-
scopeStringList.Add(scope.ToDescriptionString());
53-
}
54-
string scopeString = string.Join("+", scopeStringList);
5548

56-
await JSRuntime.InvokeVoidAsync("open", $"https://accounts.google.com/o/oauth2/auth/oauthchooseaccount?response_type=code&client_id={clientId}&scope={scopeString}&redirect_uri={encodedRedirectUrl}&flowName=GeneralOAuthFlow&access_type=offline&prompt={promptType.ToDescriptionString()}", "_blank");
49+
string encodedRedirectUrl = HttpUtility.UrlEncode(redirectUrl);
50+
51+
string encodedScopes = HttpUtility.UrlEncode(string.Join(" ", scopes.Select(x => x.ToDescriptionString())));
52+
53+
string url =
54+
$"https://accounts.google.com/o/oauth2/v2/auth" +
55+
$"?response_type=code" +
56+
$"&client_id={clientId}" +
57+
$"&scope={encodedScopes}" +
58+
$"&redirect_uri={encodedRedirectUrl}" +
59+
$"&access_type=offline" +
60+
$"&prompt={promptType.ToDescriptionString()}";
61+
62+
await JSRuntime.InvokeVoidAsync("open", url, "_blank");
5763
}
5864

5965
/// <summary>

GoogleApis.Blazor/GoogleApis.Blazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>disable</Nullable>
7-
<Version>0.3.1</Version>
7+
<Version>0.3.2</Version>
88
<PackageIcon>CodeBeam.jpg</PackageIcon>
99
<Copyright>Copyright 2026 CodeBeam</Copyright>
1010
<Description>A utility package for Google Apis in Blazor.</Description>

0 commit comments

Comments
 (0)