I have meet big problem about read mail from my outlook account, it takes me about serval days, however still failed, somebody can help me?
I am referring to this document:
https://learn.microsoft.com/en-us/graph/auth-v2-user?view=graph-rest-1.0&tabs=http
Here is my code:
Step 1: (get code)
https://login.microsoftonline.com/c4acbf1d-ea8c-4147-8bbf-23e6f48ffb3e/oauth2/v2.0/authorize?client_id=2b331fc4-2778-4ada-93c0-33cbbbeed6db&response_type=code&redirect_uri=http://localhost:8888/auth&response_mode=query&scope=offline_access%20User.Read%20Mail.Read%20Mail.ReadBasic&state=test123
code is: 1.AcYAHb-sxIzqR0GLvyPm9I_7PsQfMyt4J9pKk8Azy7vu1tvpAADGAA.AgABBAIAAABVrSpeuWamRam2jAF1XRQEAwDs_wUA9P_7JtLMtdErg-aeUPnOQWCp.......
Step 2: (get token)
Then i got token and refresh token, scope is correct
Step 3: (test get users)
Yes, successfully get user info.
Step 4: (test get user mail messages)
Unfortunately, it failed, i don't know why and how to fix it, please help, thanks.
This is my request header: Req header snapshot
While when i use another mode, Get access without a user, still have the same problem, Of course, I used another method to obtain the new token, which is valid because I have already obtained the user's ID. the doc: https://learn.microsoft.com/en-us/graph/auth-v2-service?tabs=http
GET https://graph.microsoft.com/v1.0/users/9dfb85a5-b8bb-4e7d-8e05-a60d418ca16d/messages?$select=sender,subject
Authorization: Bearer ey.....TJxBtlAXdJARLAJP4KcQ9mnA
User-Agent: IntelliJ HTTP Client/IntelliJ IDEA 2024.2.1
Accept-Encoding: br, deflate, gzip, x-gzip
Accept: */*
content-length: 0
Reponse:
HTTP/2 401 Unauthorized
cache-control: private
strict-transport-security: max-age=31536000
request-id: 7e3e5860-1bf0-4d7f-8701-c593b759f488
client-request-id: 7e3e5860-1bf0-4d7f-8701-c593b759f488
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"Korea Central","Slice":"E","Ring":"4","ScaleUnit":"003","RoleInstance":"SE1PEPF0001058B"}}
date: Fri, 09 May 2025 06:39:00 GMT
content-length: 0
x-http2-stream-id: 3
<Response body is empty>
Response code: 401 (Unauthorized); Time: 1563ms (1 s 563 ms); Content length: 0 bytes (0 B)







实际请求. If the token's expired, it can also cause401 error.