-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
100 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace PixelsServer | ||
{ | ||
public static class OAuth | ||
{ | ||
public static string GetOAuthUrl(string clientId, string redirectUri, string scope, string state) | ||
{ | ||
return $"https://accounts.google.com/o/oauth2/v2/auth?" + | ||
// $"scope=https%3A//www.googleapis.com/auth/drive.metadata.readonly&" + | ||
$"response_type=code&" + | ||
$"redirect_uri={redirectUri}&" + | ||
$"client_id=client_id"; | ||
} | ||
|
||
static string GenerateGoogleAuthUrl() | ||
{ | ||
// Replace with your client ID and redirect URI | ||
string clientId = "YOUR_CLIENT_ID"; | ||
string redirectUri = "http://localhost:8080/oauth2callback"; | ||
string scopes = "openid%20email"; | ||
return $"https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id={clientId}&redirect_uri={redirectUri}&scope={scopes}&access_type=offline"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using NetCoreServer; | ||
|
||
namespace PixelsServer | ||
{ | ||
public static class ResponseUtils | ||
{ | ||
public static HttpResponse MakeRedirectResponse(this HttpResponse response, string url) | ||
{ | ||
response.Clear(); | ||
response.SetBegin(301); | ||
response.SetHeader("Location", url); | ||
response.SetContentType("text/html; charset=UTF-8"); | ||
response.SetBody("Redirecting you..."); | ||
return response; | ||
} | ||
|
||
public static string? GetHeader(this HttpRequest request, string keyValue) | ||
{ | ||
for (int i = 0; i < request.Headers; ++i) | ||
{ | ||
(string key, string val) = request.Header(i); | ||
|
||
if (key == keyValue) | ||
return val; | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,6 @@ | |
<title>Document</title> | ||
</head> | ||
<body> | ||
Hello World | ||
Hello World !! | ||
</body> | ||
</html> |