通过Power Automate给用户分配license

通过Power automate 给用户分配license

1. Create AAD App Registration
2. Retrieve Token
3. Retrieve licenses list
4. Assign license
5. Remove license

 

首先需要在AAD App Registration中注册新的permission,并且把ID, Secret ID 获取到

 

这里的案例是使用21V系统的API endpoint,你需要根据你的环境找出API endpoint  API endpoints of Office 365 for China | Microsoft Docs

 

在这需要获取access token

client_id=da0443c5-4137-4261-8f1d-85c6fb0b7a71&client_secret=00n0s.uK8_XA6_NhKC8H7_X4h.72tq.BTE&resource=https://microsoftgraph.chinacloudapi.cn&grant_type=client_credentials

 

 

这里需要把返回值转换成JSON格式

{
    "type": "object",
    "properties": {
        "token_type": {
            "type": "string"
        },
        "expires_in": {
            "type": "string"
        },
        "ext_expires_in": {
            "type": "string"
        },
        "expires_on": {
            "type": "string"
        },
        "not_before": {
            "type": "string"
        },
        "resource": {
            "type": "string"
        },
        "access_token": {
            "type": "string"
        }
    }
}

 

 

 

 

 你也可以通过get请求获取到tenant下的license信息

 

 

 

可以通过POST请求来assign license

{
  "addLicenses": [
    {
      "disabledPlans": [  ],
      "skuId": "1e812b99-651f-441b-b352-e7da2d46fc22"
    }
  ],
  "removeLicenses": []
}

 

 

 

 Remove license 同样

{
  "addLicenses": [
    {
      "disabledPlans": [
        "113feb6c-3fe4-4440-bddc-54d774bf0318"
      ],
      "skuId": "eb4df4a1-51ed-47b3-a544-8be36bd05571"
    }
  ],
  "removeLicenses": [
    "1e812b99-651f-441b-b352-e7da2d46fc22"
  ]
}

 

 

posted @ 2022-02-21 23:39  TheMiao  阅读(292)  评论(4编辑  收藏  举报