Microsoft Graph API access token validation failure












1















I use this URL to get id_token:



https://login.microsoftonline.com/common/oauth2/authorize?
response_type=id_token%20code&
client_id=MY_CLIENT_GUID_ID_IN_HERE&
redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fopenid%2Freturn&nonce=alfaYYCTxBK8oypM&
state=6DnAi0%2FICAWaH14e


and this return result like this



http://localhost:3000/auth/openid/return?
code=AAA_code_in_here&
id_token=eyJ0eXAi_xxxx_yyyy_in_here&
state=6DnAi0%2FICAWaH14e&
session_state=xxxx_guid_xxxxx


and then i use the id_token to query Graph (use POST man)
Graph API to query groups



i have see this post InvalidAuthenticationToken and CompactToken issues - Microsoft Graph using PHP Curl but make no sense.










share|improve this question





























    1















    I use this URL to get id_token:



    https://login.microsoftonline.com/common/oauth2/authorize?
    response_type=id_token%20code&
    client_id=MY_CLIENT_GUID_ID_IN_HERE&
    redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fopenid%2Freturn&nonce=alfaYYCTxBK8oypM&
    state=6DnAi0%2FICAWaH14e


    and this return result like this



    http://localhost:3000/auth/openid/return?
    code=AAA_code_in_here&
    id_token=eyJ0eXAi_xxxx_yyyy_in_here&
    state=6DnAi0%2FICAWaH14e&
    session_state=xxxx_guid_xxxxx


    and then i use the id_token to query Graph (use POST man)
    Graph API to query groups



    i have see this post InvalidAuthenticationToken and CompactToken issues - Microsoft Graph using PHP Curl but make no sense.










    share|improve this question



























      1












      1








      1








      I use this URL to get id_token:



      https://login.microsoftonline.com/common/oauth2/authorize?
      response_type=id_token%20code&
      client_id=MY_CLIENT_GUID_ID_IN_HERE&
      redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fopenid%2Freturn&nonce=alfaYYCTxBK8oypM&
      state=6DnAi0%2FICAWaH14e


      and this return result like this



      http://localhost:3000/auth/openid/return?
      code=AAA_code_in_here&
      id_token=eyJ0eXAi_xxxx_yyyy_in_here&
      state=6DnAi0%2FICAWaH14e&
      session_state=xxxx_guid_xxxxx


      and then i use the id_token to query Graph (use POST man)
      Graph API to query groups



      i have see this post InvalidAuthenticationToken and CompactToken issues - Microsoft Graph using PHP Curl but make no sense.










      share|improve this question
















      I use this URL to get id_token:



      https://login.microsoftonline.com/common/oauth2/authorize?
      response_type=id_token%20code&
      client_id=MY_CLIENT_GUID_ID_IN_HERE&
      redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fopenid%2Freturn&nonce=alfaYYCTxBK8oypM&
      state=6DnAi0%2FICAWaH14e


      and this return result like this



      http://localhost:3000/auth/openid/return?
      code=AAA_code_in_here&
      id_token=eyJ0eXAi_xxxx_yyyy_in_here&
      state=6DnAi0%2FICAWaH14e&
      session_state=xxxx_guid_xxxxx


      and then i use the id_token to query Graph (use POST man)
      Graph API to query groups



      i have see this post InvalidAuthenticationToken and CompactToken issues - Microsoft Graph using PHP Curl but make no sense.







      microsoft-graph






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 23 '17 at 12:34









      Community

      11




      11










      asked Jun 16 '16 at 13:03









      RedmanRedman

      21026




      21026
























          4 Answers
          4






          active

          oldest

          votes


















          4














          OATH 2.0 requires multiple steps. The first request returns an OAUTH Code. The next step is converting that OATUH code into a Bearer Token. This is the step you are missing here.



          I would also recommend using the v2 Endpoint which is a lot easier to work with (particularly with Graph). I wrote a v2 Endpoint Primer that walks through the process and may be helpful as well.






          share|improve this answer
























          • I am using v1 endpoint, could you also see my this question? stackoverflow.com/questions/37872642/…

            – Redman
            Jun 17 '16 at 3:39











          • The same workflow (redirect->code->token) applies to v1. The reason I recommend v2 is that it is much easier to maintain and scopes are defined by the app itself rather than the registration record.

            – Marc LaFleur
            Jun 17 '16 at 16:50



















          2














          You can't use the token directly, there is one more step to exchange the code you get from the response url into token.



          Here is my C# code (using Microsoft.IdentityModel.Clients.ActiveDirectory)



                public static AuthenticationResult ExchangeCodeForToken(string InTenantName, string InUserObjId, string InRedirectUri, string InApplicationAzureClientID, string InApplicationAzureClientAppKey)
          {
          Check.Require(!string.IsNullOrEmpty(InTenantName), "InTenantName must be provided");
          Check.Require(!string.IsNullOrEmpty(InUserObjId), "InUserObjId must be provided");

          if (CanCompleteSignIn) //redirect from sign-in
          {
          var clientCredential = new ClientCredential(InApplicationAzureClientID, InApplicationAzureClientAppKey);
          var authContext = new AuthenticationContext(Globals.GetLoginAuthority(InTenantName), (TokenCache)new ADALTokenCache(InUserObjId)); //Login Authority is https://login.microsoftonline.com/TenantName
          return authContext.AcquireTokenByAuthorizationCode(VerificationCode, new Uri(InRedirectUri), clientCredential, Globals.AZURE_GRAPH_API_RESOURCE_ID); //RESOURCE_ID is "https://graph.microsoft.com/"
          }

          return null;
          }





          share|improve this answer


























          • Uhh, ohh, you just saved my day! I was working on this for 4 days!!! Thank you!

            – Mark Szabo
            Aug 5 '17 at 23:20



















          1














          To receive the access token and use it for profile requests, you don't need anything from server-side, you can implement the oAuth2 just from the client side.



          Use the following URL for login:




          https://login.microsoftonline.com/common/oauth2/authorize?client_id=YOUR_CLIENT_ID&resource=https://graph.microsoft.com&response_type=token&redirect_uri=YOUR_REDIRECT_URI&scope=User.ReadBasic.All




          After successful login, user will redirected to the page with access_token parameter. Then use the following AJAX call to fetch user info:






          var token = login_window.location.href.split('access_token=').pop().split('&')[0];
          $.ajax({
          url: "https://graph.microsoft.com/v1.0/me",
          type: "GET",
          beforeSend: function(xhr){xhr.setRequestHeader('Authorization', 'Bearer '+token);},
          success: function(data) {
          alert('Hi '+data.displayName);
          console.log(data);
          }
          });





          Note that you may need to enable oauth2AllowImplicitFlow:true setting from your Azure Active Directory application manifest file.



          Set "oauth2AllowImplicitFlow": false to "oauth2AllowImplicitFlow": true.



          Lastly, ensure that your app has required permissions for Microsoft Graph which are sign in users and View users' basic profile






          share|improve this answer































            0














            I had this issue today when I was playing with graph API, the problem in my case was how I was generating the token.



            I used postman for generating the token wherein the Auth URL section I was adding the resource = client_id whereas it should be the graph URL. After making that change I was able to make the call via postman.



            GraphApi



            In order for the above to work, please make sure your application in Azure has delegated permissions to access the Graph API.






            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37860103%2fmicrosoft-graph-api-access-token-validation-failure%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              4 Answers
              4






              active

              oldest

              votes








              4 Answers
              4






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              4














              OATH 2.0 requires multiple steps. The first request returns an OAUTH Code. The next step is converting that OATUH code into a Bearer Token. This is the step you are missing here.



              I would also recommend using the v2 Endpoint which is a lot easier to work with (particularly with Graph). I wrote a v2 Endpoint Primer that walks through the process and may be helpful as well.






              share|improve this answer
























              • I am using v1 endpoint, could you also see my this question? stackoverflow.com/questions/37872642/…

                – Redman
                Jun 17 '16 at 3:39











              • The same workflow (redirect->code->token) applies to v1. The reason I recommend v2 is that it is much easier to maintain and scopes are defined by the app itself rather than the registration record.

                – Marc LaFleur
                Jun 17 '16 at 16:50
















              4














              OATH 2.0 requires multiple steps. The first request returns an OAUTH Code. The next step is converting that OATUH code into a Bearer Token. This is the step you are missing here.



              I would also recommend using the v2 Endpoint which is a lot easier to work with (particularly with Graph). I wrote a v2 Endpoint Primer that walks through the process and may be helpful as well.






              share|improve this answer
























              • I am using v1 endpoint, could you also see my this question? stackoverflow.com/questions/37872642/…

                – Redman
                Jun 17 '16 at 3:39











              • The same workflow (redirect->code->token) applies to v1. The reason I recommend v2 is that it is much easier to maintain and scopes are defined by the app itself rather than the registration record.

                – Marc LaFleur
                Jun 17 '16 at 16:50














              4












              4








              4







              OATH 2.0 requires multiple steps. The first request returns an OAUTH Code. The next step is converting that OATUH code into a Bearer Token. This is the step you are missing here.



              I would also recommend using the v2 Endpoint which is a lot easier to work with (particularly with Graph). I wrote a v2 Endpoint Primer that walks through the process and may be helpful as well.






              share|improve this answer













              OATH 2.0 requires multiple steps. The first request returns an OAUTH Code. The next step is converting that OATUH code into a Bearer Token. This is the step you are missing here.



              I would also recommend using the v2 Endpoint which is a lot easier to work with (particularly with Graph). I wrote a v2 Endpoint Primer that walks through the process and may be helpful as well.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jun 16 '16 at 17:37









              Marc LaFleurMarc LaFleur

              19k31933




              19k31933













              • I am using v1 endpoint, could you also see my this question? stackoverflow.com/questions/37872642/…

                – Redman
                Jun 17 '16 at 3:39











              • The same workflow (redirect->code->token) applies to v1. The reason I recommend v2 is that it is much easier to maintain and scopes are defined by the app itself rather than the registration record.

                – Marc LaFleur
                Jun 17 '16 at 16:50



















              • I am using v1 endpoint, could you also see my this question? stackoverflow.com/questions/37872642/…

                – Redman
                Jun 17 '16 at 3:39











              • The same workflow (redirect->code->token) applies to v1. The reason I recommend v2 is that it is much easier to maintain and scopes are defined by the app itself rather than the registration record.

                – Marc LaFleur
                Jun 17 '16 at 16:50

















              I am using v1 endpoint, could you also see my this question? stackoverflow.com/questions/37872642/…

              – Redman
              Jun 17 '16 at 3:39





              I am using v1 endpoint, could you also see my this question? stackoverflow.com/questions/37872642/…

              – Redman
              Jun 17 '16 at 3:39













              The same workflow (redirect->code->token) applies to v1. The reason I recommend v2 is that it is much easier to maintain and scopes are defined by the app itself rather than the registration record.

              – Marc LaFleur
              Jun 17 '16 at 16:50





              The same workflow (redirect->code->token) applies to v1. The reason I recommend v2 is that it is much easier to maintain and scopes are defined by the app itself rather than the registration record.

              – Marc LaFleur
              Jun 17 '16 at 16:50













              2














              You can't use the token directly, there is one more step to exchange the code you get from the response url into token.



              Here is my C# code (using Microsoft.IdentityModel.Clients.ActiveDirectory)



                    public static AuthenticationResult ExchangeCodeForToken(string InTenantName, string InUserObjId, string InRedirectUri, string InApplicationAzureClientID, string InApplicationAzureClientAppKey)
              {
              Check.Require(!string.IsNullOrEmpty(InTenantName), "InTenantName must be provided");
              Check.Require(!string.IsNullOrEmpty(InUserObjId), "InUserObjId must be provided");

              if (CanCompleteSignIn) //redirect from sign-in
              {
              var clientCredential = new ClientCredential(InApplicationAzureClientID, InApplicationAzureClientAppKey);
              var authContext = new AuthenticationContext(Globals.GetLoginAuthority(InTenantName), (TokenCache)new ADALTokenCache(InUserObjId)); //Login Authority is https://login.microsoftonline.com/TenantName
              return authContext.AcquireTokenByAuthorizationCode(VerificationCode, new Uri(InRedirectUri), clientCredential, Globals.AZURE_GRAPH_API_RESOURCE_ID); //RESOURCE_ID is "https://graph.microsoft.com/"
              }

              return null;
              }





              share|improve this answer


























              • Uhh, ohh, you just saved my day! I was working on this for 4 days!!! Thank you!

                – Mark Szabo
                Aug 5 '17 at 23:20
















              2














              You can't use the token directly, there is one more step to exchange the code you get from the response url into token.



              Here is my C# code (using Microsoft.IdentityModel.Clients.ActiveDirectory)



                    public static AuthenticationResult ExchangeCodeForToken(string InTenantName, string InUserObjId, string InRedirectUri, string InApplicationAzureClientID, string InApplicationAzureClientAppKey)
              {
              Check.Require(!string.IsNullOrEmpty(InTenantName), "InTenantName must be provided");
              Check.Require(!string.IsNullOrEmpty(InUserObjId), "InUserObjId must be provided");

              if (CanCompleteSignIn) //redirect from sign-in
              {
              var clientCredential = new ClientCredential(InApplicationAzureClientID, InApplicationAzureClientAppKey);
              var authContext = new AuthenticationContext(Globals.GetLoginAuthority(InTenantName), (TokenCache)new ADALTokenCache(InUserObjId)); //Login Authority is https://login.microsoftonline.com/TenantName
              return authContext.AcquireTokenByAuthorizationCode(VerificationCode, new Uri(InRedirectUri), clientCredential, Globals.AZURE_GRAPH_API_RESOURCE_ID); //RESOURCE_ID is "https://graph.microsoft.com/"
              }

              return null;
              }





              share|improve this answer


























              • Uhh, ohh, you just saved my day! I was working on this for 4 days!!! Thank you!

                – Mark Szabo
                Aug 5 '17 at 23:20














              2












              2








              2







              You can't use the token directly, there is one more step to exchange the code you get from the response url into token.



              Here is my C# code (using Microsoft.IdentityModel.Clients.ActiveDirectory)



                    public static AuthenticationResult ExchangeCodeForToken(string InTenantName, string InUserObjId, string InRedirectUri, string InApplicationAzureClientID, string InApplicationAzureClientAppKey)
              {
              Check.Require(!string.IsNullOrEmpty(InTenantName), "InTenantName must be provided");
              Check.Require(!string.IsNullOrEmpty(InUserObjId), "InUserObjId must be provided");

              if (CanCompleteSignIn) //redirect from sign-in
              {
              var clientCredential = new ClientCredential(InApplicationAzureClientID, InApplicationAzureClientAppKey);
              var authContext = new AuthenticationContext(Globals.GetLoginAuthority(InTenantName), (TokenCache)new ADALTokenCache(InUserObjId)); //Login Authority is https://login.microsoftonline.com/TenantName
              return authContext.AcquireTokenByAuthorizationCode(VerificationCode, new Uri(InRedirectUri), clientCredential, Globals.AZURE_GRAPH_API_RESOURCE_ID); //RESOURCE_ID is "https://graph.microsoft.com/"
              }

              return null;
              }





              share|improve this answer















              You can't use the token directly, there is one more step to exchange the code you get from the response url into token.



              Here is my C# code (using Microsoft.IdentityModel.Clients.ActiveDirectory)



                    public static AuthenticationResult ExchangeCodeForToken(string InTenantName, string InUserObjId, string InRedirectUri, string InApplicationAzureClientID, string InApplicationAzureClientAppKey)
              {
              Check.Require(!string.IsNullOrEmpty(InTenantName), "InTenantName must be provided");
              Check.Require(!string.IsNullOrEmpty(InUserObjId), "InUserObjId must be provided");

              if (CanCompleteSignIn) //redirect from sign-in
              {
              var clientCredential = new ClientCredential(InApplicationAzureClientID, InApplicationAzureClientAppKey);
              var authContext = new AuthenticationContext(Globals.GetLoginAuthority(InTenantName), (TokenCache)new ADALTokenCache(InUserObjId)); //Login Authority is https://login.microsoftonline.com/TenantName
              return authContext.AcquireTokenByAuthorizationCode(VerificationCode, new Uri(InRedirectUri), clientCredential, Globals.AZURE_GRAPH_API_RESOURCE_ID); //RESOURCE_ID is "https://graph.microsoft.com/"
              }

              return null;
              }






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jun 17 '16 at 14:43

























              answered Jun 17 '16 at 14:37









              tatigotatigo

              1,2612128




              1,2612128













              • Uhh, ohh, you just saved my day! I was working on this for 4 days!!! Thank you!

                – Mark Szabo
                Aug 5 '17 at 23:20



















              • Uhh, ohh, you just saved my day! I was working on this for 4 days!!! Thank you!

                – Mark Szabo
                Aug 5 '17 at 23:20

















              Uhh, ohh, you just saved my day! I was working on this for 4 days!!! Thank you!

              – Mark Szabo
              Aug 5 '17 at 23:20





              Uhh, ohh, you just saved my day! I was working on this for 4 days!!! Thank you!

              – Mark Szabo
              Aug 5 '17 at 23:20











              1














              To receive the access token and use it for profile requests, you don't need anything from server-side, you can implement the oAuth2 just from the client side.



              Use the following URL for login:




              https://login.microsoftonline.com/common/oauth2/authorize?client_id=YOUR_CLIENT_ID&resource=https://graph.microsoft.com&response_type=token&redirect_uri=YOUR_REDIRECT_URI&scope=User.ReadBasic.All




              After successful login, user will redirected to the page with access_token parameter. Then use the following AJAX call to fetch user info:






              var token = login_window.location.href.split('access_token=').pop().split('&')[0];
              $.ajax({
              url: "https://graph.microsoft.com/v1.0/me",
              type: "GET",
              beforeSend: function(xhr){xhr.setRequestHeader('Authorization', 'Bearer '+token);},
              success: function(data) {
              alert('Hi '+data.displayName);
              console.log(data);
              }
              });





              Note that you may need to enable oauth2AllowImplicitFlow:true setting from your Azure Active Directory application manifest file.



              Set "oauth2AllowImplicitFlow": false to "oauth2AllowImplicitFlow": true.



              Lastly, ensure that your app has required permissions for Microsoft Graph which are sign in users and View users' basic profile






              share|improve this answer




























                1














                To receive the access token and use it for profile requests, you don't need anything from server-side, you can implement the oAuth2 just from the client side.



                Use the following URL for login:




                https://login.microsoftonline.com/common/oauth2/authorize?client_id=YOUR_CLIENT_ID&resource=https://graph.microsoft.com&response_type=token&redirect_uri=YOUR_REDIRECT_URI&scope=User.ReadBasic.All




                After successful login, user will redirected to the page with access_token parameter. Then use the following AJAX call to fetch user info:






                var token = login_window.location.href.split('access_token=').pop().split('&')[0];
                $.ajax({
                url: "https://graph.microsoft.com/v1.0/me",
                type: "GET",
                beforeSend: function(xhr){xhr.setRequestHeader('Authorization', 'Bearer '+token);},
                success: function(data) {
                alert('Hi '+data.displayName);
                console.log(data);
                }
                });





                Note that you may need to enable oauth2AllowImplicitFlow:true setting from your Azure Active Directory application manifest file.



                Set "oauth2AllowImplicitFlow": false to "oauth2AllowImplicitFlow": true.



                Lastly, ensure that your app has required permissions for Microsoft Graph which are sign in users and View users' basic profile






                share|improve this answer


























                  1












                  1








                  1







                  To receive the access token and use it for profile requests, you don't need anything from server-side, you can implement the oAuth2 just from the client side.



                  Use the following URL for login:




                  https://login.microsoftonline.com/common/oauth2/authorize?client_id=YOUR_CLIENT_ID&resource=https://graph.microsoft.com&response_type=token&redirect_uri=YOUR_REDIRECT_URI&scope=User.ReadBasic.All




                  After successful login, user will redirected to the page with access_token parameter. Then use the following AJAX call to fetch user info:






                  var token = login_window.location.href.split('access_token=').pop().split('&')[0];
                  $.ajax({
                  url: "https://graph.microsoft.com/v1.0/me",
                  type: "GET",
                  beforeSend: function(xhr){xhr.setRequestHeader('Authorization', 'Bearer '+token);},
                  success: function(data) {
                  alert('Hi '+data.displayName);
                  console.log(data);
                  }
                  });





                  Note that you may need to enable oauth2AllowImplicitFlow:true setting from your Azure Active Directory application manifest file.



                  Set "oauth2AllowImplicitFlow": false to "oauth2AllowImplicitFlow": true.



                  Lastly, ensure that your app has required permissions for Microsoft Graph which are sign in users and View users' basic profile






                  share|improve this answer













                  To receive the access token and use it for profile requests, you don't need anything from server-side, you can implement the oAuth2 just from the client side.



                  Use the following URL for login:




                  https://login.microsoftonline.com/common/oauth2/authorize?client_id=YOUR_CLIENT_ID&resource=https://graph.microsoft.com&response_type=token&redirect_uri=YOUR_REDIRECT_URI&scope=User.ReadBasic.All




                  After successful login, user will redirected to the page with access_token parameter. Then use the following AJAX call to fetch user info:






                  var token = login_window.location.href.split('access_token=').pop().split('&')[0];
                  $.ajax({
                  url: "https://graph.microsoft.com/v1.0/me",
                  type: "GET",
                  beforeSend: function(xhr){xhr.setRequestHeader('Authorization', 'Bearer '+token);},
                  success: function(data) {
                  alert('Hi '+data.displayName);
                  console.log(data);
                  }
                  });





                  Note that you may need to enable oauth2AllowImplicitFlow:true setting from your Azure Active Directory application manifest file.



                  Set "oauth2AllowImplicitFlow": false to "oauth2AllowImplicitFlow": true.



                  Lastly, ensure that your app has required permissions for Microsoft Graph which are sign in users and View users' basic profile






                  var token = login_window.location.href.split('access_token=').pop().split('&')[0];
                  $.ajax({
                  url: "https://graph.microsoft.com/v1.0/me",
                  type: "GET",
                  beforeSend: function(xhr){xhr.setRequestHeader('Authorization', 'Bearer '+token);},
                  success: function(data) {
                  alert('Hi '+data.displayName);
                  console.log(data);
                  }
                  });





                  var token = login_window.location.href.split('access_token=').pop().split('&')[0];
                  $.ajax({
                  url: "https://graph.microsoft.com/v1.0/me",
                  type: "GET",
                  beforeSend: function(xhr){xhr.setRequestHeader('Authorization', 'Bearer '+token);},
                  success: function(data) {
                  alert('Hi '+data.displayName);
                  console.log(data);
                  }
                  });






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered May 9 '17 at 18:54









                  Orhun Alp OralOrhun Alp Oral

                  439413




                  439413























                      0














                      I had this issue today when I was playing with graph API, the problem in my case was how I was generating the token.



                      I used postman for generating the token wherein the Auth URL section I was adding the resource = client_id whereas it should be the graph URL. After making that change I was able to make the call via postman.



                      GraphApi



                      In order for the above to work, please make sure your application in Azure has delegated permissions to access the Graph API.






                      share|improve this answer




























                        0














                        I had this issue today when I was playing with graph API, the problem in my case was how I was generating the token.



                        I used postman for generating the token wherein the Auth URL section I was adding the resource = client_id whereas it should be the graph URL. After making that change I was able to make the call via postman.



                        GraphApi



                        In order for the above to work, please make sure your application in Azure has delegated permissions to access the Graph API.






                        share|improve this answer


























                          0












                          0








                          0







                          I had this issue today when I was playing with graph API, the problem in my case was how I was generating the token.



                          I used postman for generating the token wherein the Auth URL section I was adding the resource = client_id whereas it should be the graph URL. After making that change I was able to make the call via postman.



                          GraphApi



                          In order for the above to work, please make sure your application in Azure has delegated permissions to access the Graph API.






                          share|improve this answer













                          I had this issue today when I was playing with graph API, the problem in my case was how I was generating the token.



                          I used postman for generating the token wherein the Auth URL section I was adding the resource = client_id whereas it should be the graph URL. After making that change I was able to make the call via postman.



                          GraphApi



                          In order for the above to work, please make sure your application in Azure has delegated permissions to access the Graph API.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 20 '18 at 20:20









                          NSDumbNSDumb

                          817613




                          817613






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37860103%2fmicrosoft-graph-api-access-token-validation-failure%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              MongoDB - Not Authorized To Execute Command

                              in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

                              Npm cannot find a required file even through it is in the searched directory