1
votes

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

2 Answers

3
votes

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.

0
votes

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.