/MSO-365-E5-AR

Primary LanguagePythonMIT LicenseMIT

MSO_E5_Dev_AR

Python application based on Git Actions that use Microsoft Graph API. This guide will provide you with easy-to-understand steps for setting up and running the application.

  • Original version address: github.com/HarryVed/Microsoft-Developer-Subscription-Renew-Free

Prerequisites

  • A GitHub account
  • An existing or new Microsoft Developer E5 account

Setup Steps (Encrypted Secure Version)

  1. Register a new application in Azure Active Directory.
    • Go to https://entra.microsoft.com/
    • Applications > App reginstrations > New registration
    • Select "Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant)"
    • Select "Web" for the redirect URL, and enter "http://localhost:53682/" for the redirect URL.
    • Save Application ID
    • Go to Certificates & Secrets > New
    • Save the Secret value.
  2. Set API permissions. (may not be required)
    • Go to API Permissions > NEW
    • Select Microsoft graph > Application permissions
    • Select the following permissions: files.read.all, files.readwrite.all, sites.read.all, sites.readwrite.all, user.read.all, user.readwrite.all, directory.read.all, directory.readwrite.all, mail.read, mail.readwrite, mailboxsetting.read, and mailboxsetting.readwrite.
    • "Grant admin consect for MSFT" for all 13 selected permissions.
  3. install rclone in your system. It is required to get refresh token (one time only)
  4. Execute the command rclone authorize "onedrive" "id" "secret".
    • id is the Application ID you get it from previous steps
    • secret is the Application secret you get it from previous steps
    • Execute, When browser window opens and MS login page shows, edit the URL's scope query part and replace its value with Mail.Read+Mail.ReadWrite+MailboxSettings.Read+MailboxSettings.ReadWrite+Directory.Read.All+Directory.ReadWrite.All+Files.Read.All+Files.ReadWrite.All+Sites.Read.All+Sites.ReadWrite.All+User.Read+User.Read.All+User.ReadWrite.All+offline_access
    • Press Enter, Select admin account.
    • on success, go to the prompt and save the refresh_token values from JSON output.
  5. Keep Application ID, Secret, Refresh_token handly you will need it in the next step
  6. Go to the project settings and from the left hand side menu select Secrets and Variables > Actions
  7. Click New repository secrets. and create three variables and set the value as given below
    • Name: CONFIG_APPID value is App ID
    • Name: CONFIG_SECRET value is App secret
    • Name: REFRESH_TOKEN value is Refresh token
  8. Goto the project setting again and choose Actions menu and scroll down until you see Workflow permissions click Read and write permission option
  9. Go to your personal settings page on GitHub, select Developer settings > Personal access tokens > Generate new token. (NOT NEEDED ANYMORE)
    • Set the name to GITHUB_TOKEN.
    • Check the options repo, admin:repo_hook, and workflow.
    • Generate the token.
  10. Go to your personal settings page on GitHub, select Developer settings > Personal access tokens > Generate new token.
    • Check the options public_repo.
    • Generate the token.
    • Copy the token.
    • Now create a new repository action secret
    • Set the name to GH_PA_TOKEN, and fill the value with personal access token value.
  11. Run the action Workflow
  12. Click on the Actions tab above to see the log of each run and check if the API is called correctly and if there are any errors.

Additional Information