MSGraph令牌错误:“在目录中找不到应用程序(...)”

时间:2017-11-08 17:22:38

标签: azure-active-directory microsoft-graph onedrive

我正在尝试在PHP中实现Microsoft Graph for OneDrive访问。我要去this documentation

我已在$LogonLink = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?". http_build_query(array( 'client_id' => $MSGraphAppID, 'response_type' => 'code', 'redirect_uri' => 'http://www.example.com/ongraph.php', 'response_mode' => 'query', 'scope' => 'offline_access Files.ReadWrite')); 注册了我的应用,并获得了应用ID和秘密。

现在,对于令牌流程,我发出以下链接:

ongraph.php

登录和权限UI按预期工作,我的应用程序名称和图标出现。因此,应用程序ID被识别。现在,$cu = curl_init('https://login.microsoftonline.com/common/oauth2/v2.0/token'); $Form = array( 'client_id' => $MSGraphAppID, 'scope' => 'offline_access Files.ReadWrite', 'code' => $_GET['Code'], 'redirect_uri' => 'http://www.example.com/ongraph.php', 'grant_type' => 'authorization_code', 'client_secret' => $MSGraphSecret ); curl_setopt_array($cu, array( CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($Form))); $r = curl_exec($cu); 通过代码获得控制权,并发出以下POST:

400

我收到错误{ "error": "unauthorized_client", "error_description": "AADSTS70001: Application with identifier '0000000048205436' was not found in the directory 9188040d-6c67-4c5b-b112-36a304b66dad\r\nTrace ID: b0f7cba6-42b3-4f37-8438-5e8566ba1300\r\nCorrelation ID: ca51b601-86cb-4801-a330-354ffd3c715f\r\nTimestamp: 2017-11-08 17:12:33Z", "error_codes": [70001], "timestamp": "2017-11-08 17:12:33Z", "trace_id": "b0f7cba6-42b3-4f37-8438-5e8566ba1300", "correlation_id": "ca51b601-86cb-4801-a330-354ffd3c715f" } 以及以下回复:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="manuela.com.messagewearableandroid">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />


        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <service
            android:name=".ListenerService"
            android:enabled="true">
            <intent-filter>
                <action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
                <action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED" />
                <data android:scheme="wear" android:host="*" />
            </intent-filter>

        </service>
    </application>

</manifest>

我在这里想念的是什么?我尝试过创建一个全新的应用注册,结果相同。

编辑:这就是应用注册网站的样子:

Registration UI screenshot

1 个答案:

答案 0 :(得分:4)

此处的问题是您已将应用注册为Live SDK application

Live SDK Application Registration

对于v2端点(和Microsoft Graph),您需要将其注册为Converged application

Converged Application

https://apps.dev.microsoft.com站点处理两种应用程序类型。