Cloudflare-Workers-E5Renew
Description
Use Cloudflare Workers to renew your E5 subscription by calling the Microsoft Graph API randomly. Not guaranteed the renewal will be successful.
Deploying
(Not sure if this button works.)
Cloudflare Workers
- Create a new Workers KV namespace.
- Create a new Cloudflare Workers service and click on the "Quick edit" button.
- Copy the contents of the index.js file into the code field and click "Save and Deploy".
- Back to workers page and go to the "Settings" tab. In the "Environment Variables" section, add the following environment variables:
CRON_PATH
: The path to trigger the cron job manually. For example:/cron
. Leave it blank if you don't want to trigger the cron job manually.TGBOT_TOKEN
: The token of the Telegram bot for sending notifications. Get it from the BotFather. Or leave it blank if you don't want to be notified.TGBOT_CHAT_ID
: The user ID that the notifications will be sent to. Get it from the userinfobot bot. Or leave it blank if you don't want to be notified.MS_CLIENT_ID
: The client id of the Microsoft application. Get it in the step below.MS_CLIENT_SECRET
: The client secret of the Microsoft application. Get it in the step below.MS_REDIRECT_URI
: The redirect uri of the Microsoft application. It should be in the format ofhttps://welcome.developers.workers.dev/callback
, wherewelcome
is the name of worker service anddevelopers
is the name your subdomain.
- In the "KV Namespace Bindings" section, add the following bindings:
Variable name
:Token
KV Namespace
: The KV namespace created in step 1.
- Go to "Triggers" tab and click on the "Add Cron Trigger" button in the "Cron Triggers" section. Choose whatever frequency you want and click "Add Trigger".
Microsoft Azure AD
- Go to the Azure portal and select "Azure Active Directory" from the menu.
- Select "App registrations" and click the "New registration" button from the top menu.
- Enter the name whatever you want for your app. For the type of supported account types, select
Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)
. - For the "Redirect URI" field, select
Web
, and in the "URL" field, enter the following URL:https://welcome.developers.workers.dev/callback
wherewelcome
is the name of worker service anddevelopers
is the name your subdomain. - Click the "Register" button.
- From the "Certificates and secrets" menu, click "Client secret" tab and click the "New client secret" button. Enter the description and select the expiration time. Click the "Add" button. The client secret will be shown in the "Value" field. Copy the client secret and paste it into the
MS_CLIENT_SECRET
environment variable of the workers service. - From the "Overview" tab, copy the "Application (client) ID" field and paste it into the
MS_CLIENT_ID
environment variable of the workers service.
Authorize
Access the Cloudflare Workers via the default route like https://welcome.developers.workers.dev/
. Click the "Authorize" button and you will be redirected to the Microsoft login page. Just click the "Accept" button and you will be redirected back to the Cloudflare Workers page. If everything is OK, "Successfully logged in" will be shown. Enjoy!