Giter VIP home page Giter VIP logo

microsoft-e5-auto-renewal's Introduction

Microsoft E5 Auto Renewal

An open-source Python program made using Quart & Uvicorn for automatic renewal of Microsoft's Developer E5 subscription.

๐Ÿ“‘ INDEX

โ“ How to use?

If you lack the knowledge to deploy your own web server, you can use a ready-to-use public instance directly by following steps given below.

  • Open below URL and get your refresh token.
    https://e5.thecaduceus.eu.org/auth
    
  • Now create a cron-job here with following configuration:
    • URL:
      https://e5.thecaduceus.eu.org/call
      
    • Headers:
      {"Content-Type":"application/json"}
    • Request Method: POST
    • Request Body:
      {"refresh_token": "YourRefreshTokenHere"}
  • You did it!๐ŸŽ‰

โš™๏ธ Installation

1.Install Python & Git:

For Windows:

winget install Python.Python.3.11
winget install Git.Git

For Linux:

sudo apt-get update && sudo apt-get install -y python3.11 git pip

For macOS:

brew install [email protected] git

For Termux:

pkg install python -y
pkg install git -y

2.Download repository:

git clone https://github.com/TheCaduceus/Microsoft-E5-Auto-Renewal.git

3.Change Directory:

cd Microsoft-E5-Auto-Renewal

4.Install requirements:

pip install -r requirements.txt

๐Ÿ“ Variables

The variables provided below should either be completed within the config.py file or configured as environment variables.

  • CLIENT_ID|E5_CLIENT_ID: ID of your Azure Active Directory app. str
    • Create an app in Azure Active Directory.
    • Set application permissions:
      Directory.Read.All,
      Directory.ReadWrite.All,
      Files.Read,
      Files.Read.All,
      Files.ReadWrite,
      Files.ReadWrite.All,
      Mail.Read,
      Mail.ReadWrite,
      MailboxSettings.Read,
      MailboxSettings.ReadWrite,
      Sites.Read.All,
      Sites.ReadWrite.All,
      User.Read,
      User.Read.All,
      User.ReadWrite.All
      
    • Choose application type as 'Web' & set Redirect URL to http://localhost:53682/.
    • Copy the Application (client) ID.
  • CLIENT_SECRET|E5_CLIENT_SECRET: Secret of your Azure Active Directory app. str
    • In your Azure Active Directory app overview, navigate to Client credentials and create secret.
  • REFRESH_TOKEN|E5_REFRESH_TOKEN: Refresh token for your admin account. str
    • In CLI, run:
      python auth.py YourClientID YourClientSecret
      
    • Follow on-screen instructions.
    • From output, copy the value of refresh_token key.
  • WEB_APP_PASSWORD|E5_WEB_APP_PASSWORD: Strong password to protect critical routes of your web server. str
    • Keep it strong and don't share it.
  • WEB_APP_HOST|E5_WEB_APP_HOST: Bind address of web server. str
    • By default 0.0.0.0 to run on all possible addresses.
  • WEB_APP_PORT|PORT: Port for web server to listen to. int
    • By default 8080.
  • TIME_DELAY|E5_TIME_DELAY: Time (in seconds) to wait before calling another endpoint. int
    • By default 3 seconds.

๐Ÿ•น Deployment

1.Running locally: (Best for testing)

python main.py

2.Using Docker: (Recommended)

  • Build own Docker image:
docker build -t msft-e5-renewal .
  • Run the Docker container:
docker run -p 8080:8080 msft-e5-renewal

3.Deployment on Cyclic: (Easiest & Free)

  • Sign-up on Cyclic here.
  • Click deployment button given below:
    Deploy to Cyclic
  • Select main.py as main file and cyclic as branch.
  • Switch to 'Variables' tab and set all environment variables (starting with E5_) except PORT given above.
  • Click "Connect Cyclic" and it will be deployed automatically.
  • Finally, you can create cron-job using your Cyclic app endpoint as mentioned here.

Note

Due to the read-only file system provided by Cyclic, the /logs route is disabled.

๐ŸŒ Routes

  • / - GET

    Retrieve server statistics in JSON format, including the server version, total received requests, total successful requests, and the total number of errors encountered thus far.

    • Headers:
      • None.
    • Parameters:
      • None.
    • Example:
      curl http://127.0.0.1:8080/
  • /call - POST

    Command server to call Microsoft APIs on behalf of a user account.

    • Headers:
      {"Content-Type":"application/json"}
    • Parameters: (as JSON)
      • password (required) - The web app password.
      • client_id (optional) - ID of your Azure Active Directory app. By default provided client ID in config.py.
      • client_secret (optional) - Secret of your Azure Active Directory app. By default provided client secret in config.py.
      • refresh_token (optional) - The refresh token of user account to act behalf of. By default provided refresh token in config.py.
    • Example:
      curl -X POST -H "Content-Type: application/json" -d '{"password":"RequiredPassword", "refresh_token": "OptionalRefreshToken"}' "http://127.0.0.1:8080/call"
  • /logs - GET

    Generate download request for current log file.

    • Headers:
      • None.
    • Parameters: (in URL)
      • password (required) - The web app password.
      • as_file (optional) - By default, this parameter is set to False, allowing you to choose whether to send logs as a file with options True or False.
    • Example
      curl -o "event-log.txt" "http://127.0.0.1:8080/logs?password=1234&as_file=True"

โฐ Cron-Job

The Cron-Job will instruct our web server to invoke Microsoft APIs at regular intervals. To ensure proper functionality, the configuration of the cron-job must align with the following settings:

  • URL: Server address, can be an FQDN or an IP address followed by /call.

    • In case of local deployment (private IP), you must setup cron-job on the same local network or reverse DNS.

      https://example.com/call
      http://127.0.0.1:8080/call
      
  • Interval: 15 minutes - 8 hours.

    • A too-small interval can lead to API flooding issues.
  • Header:

    {"Content-Type":"application/json"}
  • Request Method: POST

  • Parameters: (as Json)

    • password (required) - Your WEB_APP_PASSWORD to ensure that this request originates from a trusted source.

    • refresh_token (optional) - The refresh token of the user account to act behalf of. By default, the refresh token provided in config.py.

      {
        "password": "RequiredPassword",
        "refresh_token": "OptionalRefreshToken"
      }

โ›‘๏ธ Need help!

  • Ask questions or doubts here.

โค๏ธ Credits & Thanks

Dr.Caduceus: Owner & developer of Microsoft E5 Auto Renewal Tool.

microsoft-e5-auto-renewal's People

Contributors

thecaduceus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.