1

I am trying to get my office365 planner task using the Microsoft Graph API but I am getting below error:

GET https://graph.microsoft.com/beta/me/tasks

{
  "error": {
    "code": "InvalidAuthenticationToken",
    "message": "Bearer access token is empty.",
    "innerError": {
      "request-id": "4f209643-f3f6-4256-87b7-cf4f2fd489eb",
      "date": "2016-05-16T09:03:33"
    }
  }
}

2 Answers 2

3

The error message is pretty self-explanatory,

"message": "Bearer access token is empty."

You need to be authenticated before you can make this RESTful API call.

If you're developing your own app, follow this tutorial to learn about OAuth2 workflow, http://graph.microsoft.io/en-us/docs/platform/rest

If you're using Graph Explore, make sure you're logged in before call that API.

5
  • When i try to login through Graph Explore it gives me below error AADSTS90093: Calling principal cannot consent due to lack of permissions. What are the steps need to be perform for getting permission , please suggest as i am new to Graph-API and Azure AD.
    – SSK
    May 17, 2016 at 8:33
  • Are you logged in as an admin user? You need to log in as an admin or try to consent the user with the proper rights.
    – Jackie
    May 18, 2016 at 1:17
  • Hi Jackie : I tried login with admin user too for sign in but same error . also where & how can i consent the user with proper rights ? kindly note i am accessing the api through Graph Explore .
    – SSK
    May 18, 2016 at 7:43
  • 1
    Any updates on this? Really frustrating that MS doesn't provide any easy way to test MS Graph....
    – empz
    Jun 27, 2016 at 21:57
  • Update : You, now, have a link to modify your rights from graph explorer, but it generate an error when attempting (even with tenant admin account). Cheers Feb 18, 2018 at 10:36
0

I use this Controller's action code for granting admin consent:

//<Summary>
    //Used to grant admin consent to Azure AD apps
    //</Summary>
    public virtual ActionResult AdminConsentApp()
    {
        string strResource = "https://graph.microsoft.com";
        string strRedirectController = "https://localhost:[my local debug port number]";

        string authorizationRequest = String.Format(
            "https://login.windows.net/common/oauth2/authorize?response_type=code&client_id={0}&resource={1}&redirect_uri={2}&prompt={3}",
                Uri.EscapeDataString(SettingsHelper.ClientId),
                Uri.EscapeDataString(strResource),
                Uri.EscapeDataString(String.Format("{0}", strRedirectController)),
                Uri.EscapeDataString("admin_consent")
                );

        return new RedirectResult(authorizationRequest);
    }

Hope this help, Cheers, Danfer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.