正确的方式来请求onedrive

时间:2017-02-15 09:14:28

标签: azure microsoft-graph

我正在尝试向OneDrive提出请求,但到目前为止还没有成功。我已经能够获得我认为很好的访问令牌,因为我可以从https://graph.microsoft.com/v1.0/me访问信息。但是当我尝试访问https://graph.microsoft.com/v1.0/me/drive时,我得到500个错误响应,这就是响应对象所说的:

[message:protected] => Unable to resolve template token
[string:Exception:private] => 
[code:protected] => 500
[file:protected] => C:\xampp\htdocs\OneDrive\vendor\thenetworg\oauth2-azure\src\Provider\Azure.php
[line:protected] => 68
[trace:Exception:private] => Array
    (
        [0] => Array
            (
                [file] => C:\xampp\htdocs\OneDrive\vendor\league\oauth2-client\src\Provider\AbstractProvider.php
                [line] => 644
                [function] => checkResponse
                [class] => TheNetworg\OAuth2\Client\Provider\Azure
                [type] => ->
                [args] => Array
                    (
                        [0] => GuzzleHttp\Psr7\Response Object
                            (
                                [reasonPhrase:GuzzleHttp\Psr7\Response:private] => Internal Server Error
                                [statusCode:GuzzleHttp\Psr7\Response:private] => 500
                                [headers:GuzzleHttp\Psr7\Response:private] => Array
                                    (
                                        [Cache-Control] => Array
                                            (
                                                [0] => private
                                            )

                                        [Transfer-Encoding] => Array
                                            (
                                                [0] => chunked
                                            )

                                        [Content-Type] => Array
                                            (
                                                [0] => application/json
                                            )

                                        [request-id] => Array
                                            (
                                                [0] => 7fc5c1c8-bd33-4788-bae9-5887d261c8c5
                                            )

                                        [client-request-id] => Array
                                            (
                                                [0] => 7fc5c1c8-bd33-4788-bae9-5887d261c8c5
                                            )

                                        [x-ms-ags-diagnostic] => Array
                                            (
                                                [0] => {"ServerInfo":{"DataCenter":"West Europe","Slice":"SliceB","ScaleUnit":"003","Host":"AGSFE_IN_2","ADSiteName":"AMS"}}
                                            )

                                        [Duration] => Array
                                            (
                                                [0] => 177.0851
                                            )

                                        [Date] => Array
                                            (
                                                [0] => Mon, 06 Feb 2017 12:55:27 GMT
                                            )

                                    )

                                [headerNames:GuzzleHttp\Psr7\Response:private] => Array
                                    (
                                        [cache-control] => Cache-Control
                                        [transfer-encoding] => Transfer-Encoding
                                        [content-type] => Content-Type
                                        [request-id] => request-id
                                        [client-request-id] => client-request-id
                                        [x-ms-ags-diagnostic] => x-ms-ags-diagnostic
                                        [duration] => Duration
                                        [date] => Date
                                    )

                                [protocol:GuzzleHttp\Psr7\Response:private] => 1.1
                                [stream:GuzzleHttp\Psr7\Response:private] => GuzzleHttp\Psr7\Stream Object
                                    (
                                        [stream:GuzzleHttp\Psr7\Stream:private] => Resource id #79
                                        [size:GuzzleHttp\Psr7\Stream:private] => 237
                                        [seekable:GuzzleHttp\Psr7\Stream:private] => 1
                                        [readable:GuzzleHttp\Psr7\Stream:private] => 1
                                        [writable:GuzzleHttp\Psr7\Stream:private] => 1
                                        [uri:GuzzleHttp\Psr7\Stream:private] => php://temp
                                        [customMetadata:GuzzleHttp\Psr7\Stream:private] => Array
                                            (
                                            )

                                    )

                            )

                        [1] => Array
                            (
                                [error] => Array
                                    (
                                        [code] => InternalServerError
                                        [message] => Unable to resolve template token
                                        [innerError] => Array
                                            (
                                                [request-id] => 7fc5c1c8-bd33-4788-bae9-5887d261c8c5
                                                [date] => 2017-02-06T12:55:28
                                            )

                                    )

                            )

                    )

            )

1 个答案:

答案 0 :(得分:0)

问题是我使用的是官方文档推荐的thephpleague/oauth2包。指向令牌和授权URL的链接不是v2.0端点。