1
votes

On making Rest call to Microsoft Graph API for creating groups and team, I am getting 401 unauthorized error thru my java code. Although with the same access token I am able to create the same via postman, cross checked the scope, all looks fine. Please help.

Below is the error message received :

"errorMessage": "401 Unauthorized: [{\r\n \"error\": {\r\n
\"code\": \"InvalidAuthenticationToken\",\r\n \"message\": \"Access token validation failure.\",\r\n \"innerError\": {\r\n
\"date\": \"2020-06-12T11:49:22\",\r\n \"request-id\": \"7988bd2e-3274-49e7-8c00-aa52094eab99\"\r\n }\r\n }\r\n}]"

1
can you paste java code without access token and refresh token?Sagar Rana Magar
Have you tried with Graph explorer? Can you please let us know which permission you are using to create the group?Sruthi J

1 Answers

0
votes

If you're sure it is the exact same token (copying the value out of the debugger when running your code and using it in Postman), then there's some issue with how your app is adding the token to requests. This can happen if you're not forming your Authorization header correctly. It should be formed like:

Authorization: Bearer <token>

Things to look for:

  • Not putting Bearer in front of the token
  • Not including a single space between Bearer and the token
  • Not including the entire token for some reason (truncating the value, etc.)

You should also verify what's going over the wire using Fiddler or some similar program to capture the requests.