A .NET 10 application designed to automate the extraction of one-time access codes from emails (e.g., Disney+) and deliver them directly to authorized users via Discord.
- Automated Email Scanning: On-demand scanning of Gmail for specific service emails.
- Discord Integration: Receive access codes through Discord bot commands.
- Whitelist System: Secure access control ensuring only authorized Discord users can request codes.
- OAuth 2.0 Authentication: Secure integration with Google Gmail API.
- JWT Authorization: Secure API endpoints for management.
- Docker Ready: Easy deployment using containerization.
- Framework: .NET 10.0
- Language: C# 14
- Database: PostgreSQL
- ORM: Entity Framework Core
- Discord Library: DSharpPlus
- Email API: Google Gmail API
- Containerization: Docker
- .NET 10 SDK (for local development)
- PostgreSQL instance
- Google Cloud Project:
- Enabled Gmail API.
- OAuth 2.0 Credentials (ClientId, ClientSecret).
- Discord Bot Token:
- Create a bot on the Discord Developer Portal.
- Required Gateway Intents:
Message Content.
The application requires several configuration settings in appsettings.json. You can use appsettings.json.example as a template.
ConnectionStrings:Default: PostgreSQL connection string.
GoogleAuth:ClientId: Your Google Client ID.GoogleAuth:ClientSecret: Your Google Client Secret.GoogleAuth:RedirectUri: The callback URL for OAuth (e.g.,https://localhost:7226/googleauth/callback).
Discord:Token: Your Discord Bot Token.
Configure the email patterns to search for:
{
"ProviderEmails": [
{
"Provider": "DisneyPlus",
"Email": "disneyplus@trx.mail2.disneyplus.com",
"Subject": "Jednorazowy kod dostępu do Disney+"
}
]
}- Clone the repository.
- Configure
appsettings.jsonwith your credentials. - Apply migrations:
dotnet ef database update
- Run the application:
dotnet run --project one-time_access_code_extractor
- Create an external network for the application to communicate with other containers (e.g., PostgreSQL):
docker network create backend
- Configure
one-time_access_code_extractor/appsettings.Production.jsonwith your actual credentials and connection string.- Note: The application runs in
Productionmode in Docker, so it usesappsettings.Production.jsonfor configuration. - Note for Local Database Tunnels: If you are tunneling a database from a VPS to your local
5432port, usehost.docker.internalinstead of127.0.0.1orlocalhostin your connection string (e.g.,Host=host.docker.internal;Port=5432;...). - Note for Containerized Database: If your PostgreSQL is running in another Docker container on the same
backendnetwork, use the container name as the host in your connection string (e.g.,Host=postgres-db;Port=5432;...).
- Note: The application runs in
- Start the application:
docker compose up -d --build
- Configure
one-time_access_code_extractor/appsettings.Production.jsonwith your actual credentials and connection string. - Build the image:
docker build -t access-code-extractor -f one-time_access_code_extractor/Dockerfile . - Run the container:
docker run -d --name access-code-extractor -p 8080:8080 access-code-extractor
- Authorize Gmail:
- Start the application.
- Navigate to
/GoogleAuth/Loginto authorize the app to read your emails.
- Discord Commands:
!ping: Check if the bot is alive.!disneyplus: Request the latest Disney+ access code (requires whitelist).
one-time_access_code_extractor/Configuration: Dependency injection and app setup.one-time_access_code_extractor/Controllers: API endpoints for Auth and Whitelist management.one-time_access_code_extractor/Data: Entity Framework context and migrations.one-time_access_code_extractor/Entities: Database models.one-time_access_code_extractor/Services: Business logic (Discord, Gmail, Auth).one-time_access_code_extractor/Repositories: Data access layer.