gpt4 book ai didi

live-sdk - Microsoft Live API - 访问 token 无效

转载 作者:行者123 更新时间:2023-12-04 04:40:32 27 4
gpt4 key购买 nike

我正在尝试实现“使用 Outlook.com 登录”流程,其中涉及客户端和服务器代码。
流程是:

  • 从客户端将用户重定向到:

  • https://login.live.com/oauth20_authorize.srf?client_id=< client_id >&response_type=code&redirect_uri=< the login html page >&scope=openid+offline_access+profile+https:%2f%2foutlook.office.com%2fmail.send+https:%2f%2foutlook.office.com%2fcontacts.read+onedrive.readwrite
  • 我将代码返回到我的 html 页面并将其发布到我的 java 服务器。
  • 服务器端我使用代码获取访问和刷新 token ,使用 POST 请求:
    https://login.live.com/oauth20_token.srf

  • 正文中的下一个参数:client_id、redirect_uri、client_secret、grant_type="authorization_code"和 code=< 上一步的代码 >。

    我收到了 access_token 和 refresh_tokem,它们的有效期应该是 1 小时。
  • 仍然在服务器上,我调用 URL

  • https://apis.live.net/v5.0/me?access_token= <我刚刚得到的访问 token >

    并得到错误 401:
    {
    "error": {
    "code": "request_token_invalid",
    "message": "The access token isn't valid."
    }
    }

    这个流量可以吗?

    最佳答案

    我终于能够让这个工作。

    首先,获取用户信息的正确端点是:
    https://graph.microsoft.com/v1.0/me

    其次,步骤1中的范围不应该设置为openid ...而是 User.Read .

    关于live-sdk - Microsoft Live API - 访问 token 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39305655/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com