├── .github └── workflows │ └── autoTestApi.yml ├── README.md ├── Secret.txt ├── test.py └── time.log /.github/workflows/autoTestApi.yml: -------------------------------------------------------------------------------- 1 | name: Auto Test MS Graph API 2 | 3 | on: 4 | release: 5 | types: [published] 6 | push: 7 | branches: 8 | - main 9 | # schedule: 10 | # - cron: '0 0/3 * * *' 11 | workflow_dispatch: 12 | 13 | jobs: 14 | Task: 15 | runs-on: ubuntu-22.04 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@main 19 | - name: Set up Python #安装python 20 | uses: actions/setup-python@v4 21 | with: 22 | python-version: 3.8 23 | - name: Install requests #安装requests 24 | run: | 25 | pip install requests 26 | - name: Read config from secrets #读取机密 27 | env: 28 | CONFIG_ID: ${{ secrets.CONFIG_ID }} # secrets_id 提供 29 | CONFIG_KEY: ${{ secrets.CONFIG_KEY }} # secrets_key 提供 30 | run: | 31 | cp test.py 2.py 32 | echo $CONFIG_ID > configid.txt 33 | echo $CONFIG_KEY > configkey.txt 34 | sed -i '10 r configid.txt' 2.py 35 | sed -i '12 r configkey.txt' 2.py 36 | - name: Test Api #Api调用 37 | run: | 38 | echo `date +"%Y-%m-%d %H:%M:%S"` begin > time.log 39 | python 2.py 40 | - name: Delete secrets config #删除机密 41 | run: | 42 | rm -f 2.py 43 | rm -f configid.txt 44 | rm -f configkey.txt 45 | - name: Commit #上传新的refresh_token到仓库 46 | run: | 47 | git config --global user.email chrisvcg_msdev@outlook.com 48 | git config --global user.name chrisvcg_msdev 49 | git add . 50 | git commit -m "update new refresh token with GitAction" -a 51 | - name: Push changes 52 | uses: ad-m/github-push-action@master 53 | with: 54 | github_token: ${{ secrets.GITHUB_TOKEN }} 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MSO_E5_Dev_AutoRenew_Modified 2 | This is a python program based on Git Actions modified to automatically generate development actions via Microsoft Graph API like a real developer in order to active Microsoft Office 365 E5 Developer Trail subscription auto renew. 3 | 4 | # Notice 5 | This repo may lead to unknown issues, problems, information leaks, etc. 6 | 7 | Use at your own risk. 8 | 9 | The author DO NOT provide help or further assistance for personal reasons. 10 | 11 | Please DO NOT open issues or PR over this project, I do not have enough time to respond due to personal reasons, thanks for understanding. 12 | 13 | # Update 14 | ## 2023-02-24 0:36 15 | GitAction skipp problem(https://github.com/zhtok/MSO_E5_Dev_AutoRenew_Modified/issues/4) fixed. (thanks for notifying) 16 | - Nodejs version is incompatible with the code in ```main.py```. 17 | - Certain MS Graph APIs are updated with slightly changes. 18 | 19 | Major changes are made: 20 | - Remove ```main.py``` 21 | - New ```test.py``` 22 | - New ```autoTestApi.yml``` 23 | - Import ```random``` to generate the number of tests instead of fixed 10 times for each action. 24 | - From ```ubuntu-latest``` to ```ubuntu-22.04``` 25 | - From ```actions/setup-python@v2``` to ```actions/setup-python@v4``` 26 | -------------------------------------------------------------------------------- /Secret.txt: -------------------------------------------------------------------------------- 1 | 0.AVYACNbLajfCBECSsnFfj2RDA4X2c7CzkBdPjaDSpi7reyufAG0.AgABAAEAAAD--DLA3VO7QrddgJg7WevrAgDs_wUA9P-DjQtOEIZe5sdsBDyFuTF5s94B8bV6xraNlkboEgcQO6Hnxs8wwNFgjJqyBHHI30RbOtYQvwUCXnWmYz9FX6xe2OkdT2oe-Lv-jDeks5C-2IwICsKQ237Y8qEL5lfVIlmnGHjaY_VuOre9OEh_oMnznWBmw2jHPXQ05fkJjfkuCNrzvZ16D33U_nhWK1cogw2qt3bdvNiH5ty3ggKk5SdFJKfCAkVHRBxT95D2EIuZ_LwXRY4AmwDzzP2UXzqyF_MJaR0qheDXtHQoubkvLFBCqTPncNljarlC_xL1EIrLWKQw_wRBy93E4Dg7xR4esg-6NhLvJD8AKOFwCvaXgqqaQFGt-j_yXkF89iYB7XM3K96bppj0vUSYviqaexn12Gxf8-f9b8H5O4vVF5EJ8cySYcPVkbedIWLBeSAildzhxDe4gm72kjtrs5MsJ4T5j5Tv5gQQHzbY0clhrx-lxpogYO-MYR_byFATFw_LGau9Hf2EugU5L1XARXOJoGIJc6Yq9IBjVH3arYOKLnkC8qJluX0v_3LD4d5NXW6BL8yeO678cvNN25Qq3HgvL4BgAgSr89YjM0hN1vTMUkWBqIqFU7o-RAWYhJ1pGJXwPUaz4DOoZURn8OJSXA4RicbEdWW22yUQ4O4RUh0RS3GGX7g00HbclL-s0FU10yny5pexGSoinT-UgMD2gzRuc2hSawuBvgmrA75FQdBFypbQzXie7LgI83lOx_tlPGE18y24p_GeSQHOeQ -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | # -*- coding: UTF-8 -*- 2 | import requests as req 3 | import json,sys,time 4 | #先注册azure应用,确保应用有以下权限: 5 | #files: Files.Read.All、Files.ReadWrite.All、Sites.Read.All、Sites.ReadWrite.All 6 | #user: User.Read.All、User.ReadWrite.All、Directory.Read.All、Directory.ReadWrite.All 7 | #mail: Mail.Read、Mail.ReadWrite、MailboxSettings.Read、MailboxSettings.ReadWrite 8 | #注册后一定要再点代表xxx授予管理员同意,否则outlook api无法调用 9 | 10 | 11 | 12 | 13 | 14 | 15 | path=sys.path[0]+r'/Secret.txt' 16 | num1 = 0 17 | 18 | def gettoken(refresh_token): 19 | headers={'Content-Type':'application/x-www-form-urlencoded' 20 | } 21 | data={'grant_type': 'refresh_token', 22 | 'refresh_token': refresh_token, 23 | 'client_id':id, 24 | 'client_secret':secret, 25 | 'redirect_uri':'http://localhost:53682/' 26 | } 27 | html = req.post('https://login.microsoftonline.com/common/oauth2/v2.0/token',data=data,headers=headers) 28 | jsontxt = json.loads(html.text) 29 | refresh_token = jsontxt['refresh_token'] 30 | access_token = jsontxt['access_token'] 31 | with open(path, 'w+') as f: 32 | f.write(refresh_token) 33 | return access_token 34 | def main(): 35 | fo = open(path, "r+") 36 | refresh_token = fo.read() 37 | fo.close() 38 | global num1 39 | localtime = time.asctime( time.localtime(time.time()) ) 40 | access_token=gettoken(refresh_token) 41 | headers={ 42 | 'Authorization':access_token, 43 | 'Content-Type':'application/json' 44 | } 45 | try: 46 | if req.get(r'https://graph.microsoft.com/v1.0/me/drive/root',headers=headers).status_code == 200: 47 | num1+=1 48 | print("1调用成功"+str(num1)+'次') 49 | if req.get(r'https://graph.microsoft.com/v1.0/me/drive',headers=headers).status_code == 200: 50 | num1+=1 51 | print("2调用成功"+str(num1)+'次') 52 | if req.get(r'https://graph.microsoft.com/v1.0/drive/root',headers=headers).status_code == 200: 53 | num1+=1 54 | print('3调用成功'+str(num1)+'次') 55 | if req.get(r'https://graph.microsoft.com/v1.0/users',headers=headers).status_code == 200: 56 | num1+=1 57 | print('4调用成功'+str(num1)+'次') 58 | if req.get(r'https://graph.microsoft.com/v1.0/me/messages',headers=headers).status_code == 200: 59 | num1+=1 60 | print('5调用成功'+str(num1)+'次') 61 | if req.get(r'https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messageRules',headers=headers).status_code == 200: 62 | num1+=1 63 | print('6调用成功'+str(num1)+'次') 64 | if req.get(r'https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages/delta',headers=headers).status_code == 200: 65 | num1+=1 66 | print('7调用成功'+str(num1)+'次') 67 | if req.get(r'https://graph.microsoft.com/v1.0/me/drive/root/children',headers=headers).status_code == 200: 68 | num1+=1 69 | print('8调用成功'+str(num1)+'次') 70 | if req.get(r'https://api.powerbi.com/v1.0/myorg/apps',headers=headers).status_code == 200: 71 | num1+=1 72 | print('8调用成功'+str(num1)+'次') 73 | if req.get(r'https://graph.microsoft.com/v1.0/me/mailFolders',headers=headers).status_code == 200: 74 | num1+=1 75 | print('9调用成功'+str(num1)+'次') 76 | if req.get(r'https://graph.microsoft.com/v1.0/me/outlook/masterCategories',headers=headers).status_code == 200: 77 | num1+=1 78 | print('10调用成功'+str(num1)+'次') 79 | print('此次运行结束时间为 :', localtime) 80 | except: 81 | print("pass") 82 | pass 83 | for _ in range(5): 84 | main() 85 | -------------------------------------------------------------------------------- /time.log: -------------------------------------------------------------------------------- 1 | 2023-05-01 11:03:52 begin 2 | --------------------------------------------------------------------------------