解决使用Microsoft Graph OAuth获取令牌时,没有refresh_token的问题

今天在使用Microsoft Graph 的时候,发现按照官方文档,无论如何都不能获取refresh_token,其他都没问题,经过查询,发现是因为在第一步,获取code授权时,没有给离线权限(offline_access)。

加上就可以了。

代码片段:

    {
      client_id: 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx',
      response_type: 'code',
      redirect_uri: 'http://localhost:3000/callback',
      response_mode: 'query', 
      scope: 'user.read offline_access',
    };

 

注意标红位置。

参考资料:https://stackoverflow.com/questions/42533257/receiving-access-token-but-not-the-refresh-token-from-microsoft-graph-api

 

有空详细总结一下 Microsoft Graph api的使用。

 

posted @ 2019-05-18 13:34  alpiny  阅读(1358)  评论(0编辑  收藏  举报