惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

博客园 - 咒语

跨线程 操作Winform 主UI时的扩展方法 每当双11来时,商家与京东的那些骚操作,京东30天保价不能信 Microsoft.Extensions.DependencyInjection 阅读笔记 EasyToLearnDesignPattern C#中关于表达式与委托在EF中的不同表现总结 软件开发中的版本号 The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported. ABP项目依赖图,根据自已生在的Demo项目分析而得 学习ELk之----02. Elastic Search操作入门 学习ELK之----01.建立ELK测试项目 一目了然呀的VS2017 Live Test 在Hyper-V上安装RemixOS 的Android模拟器 配置Asp.Net Web项目NLog配置文件的位置 配置WinRM的Https 测试EntityFramework,Z.EntityFramework.Extensions,原生语句在不同的查询中的表现。原来池化与非池化设定是有巨大的影响的。 消费RabbitMQ时的注意事项,如何禁止大量的消息涌到Consumer RabbitMQ调试与测试工具-v1.0.1 -提供下载测试与使用 安装TFS2015后启用生成功能 log4net在Realse下有个好大的坑呀。
Azure OAuth2 PostMan 授权代码
咒语 · 2022-01-07 · via 博客园 - 咒语

2022-01-07 10:46  咒语  阅读(237)  评论()    收藏  举报

//config varibales
const tokenLifeTime = 59;//minute
pm.environment.set('tenantDomain', 'dev.onmicrosoft.com') // Directories + subscriptions
pm.environment.set('client_credentials', 'client_credentials') // type
pm.environment.set('clientId', 'de1d0d77-') //
pm.environment.set('clientSecret', 'fUA=') //
pm.environment.set('resource', 'http://dev.com/cloudservices/system/test1/agent') //ResourcesId

//check bearerToken.
var oldToken = pm.environment.get('bearerToken');
var bearerTime = pm.environment.get('bearerTime');//last update bearerToken time 
var noToken = oldToken == undefined || oldToken == null || oldToken.trim() == '';
var expired = bearerTime == undefined || (new Date(bearerTime).addMinutes(tokenLifeTime) - new Date()) < 0;
if (noToken || expired) {
    console.log('BearerToken has expired.')
    pm.sendRequest(
        {
            url: 'https://login.microsoftonline.com/' + pm.environment.get('tenantDomain') + '/oauth2/token',
            method: 'POST',
            header: 'Content-Type: application/x-www-form-urlencoded',
            body: {
                mode: 'urlencoded',
                urlencoded: [
                    { key: 'grant_type', value: 'client_credentials', disabled: false },
                    { key: 'client_id', value: pm.environment.get('clientId'), disabled: false, },
                    { key: 'client_secret', value: pm.environment.get('clientSecret'), disabled: false, },
                    //{ key: 'scope', value: pm.environment.get('scope'), disabled: false },
                    { key: 'resource', value: pm.environment.get('resource'), disabled: false },
                ],
            },
        },
        function (err, res) {
            //pm.globals.set('bearerToken', res.json().access_token)
            pm.environment.set('bearerToken', res.json().access_token)
            pm.environment.set('bearerTime', new Date())
            console.log(pm.environment.get('bearerToken'))
        },
    )
} else {
    console.log('BearerToken is exist and life is ok.')
}

将上述代码置于左建点击某一Collection的Pre-request Script 后,再选中AuthorizationTab页修改为: