Unable to generate access token. invalid_grant error, AADSTS65001:The user or administrator has not consented to use the application with ID

Context: I’m building a web app that intends to provide insights and analysis on user’s Sharepoint and OneDrive data. Users should be able to come to my web app, connect their Sharepoint and OneDrive data by going through some oauth flow and agreeing to ‘read’ scopes we want on their workspace data, and then we should be able to generate an access and refresh token on their behalf for usage in our app according to the scopes they agreed to. For example we want to be able to search over a user’s sharepoint data given some input query.

Problem: I continue to face this error trying to generate an access token:

400 Bad Request: "{"error":"invalid_grant","error_description":"AADSTS65001: The user or administrator has not consented to use the application with ID 'fa30181d-73e3-4ac8-bc74-cdb9323c19f6' named 'appTesting'. Send an interactive authorization request for this user and resource. Trace ID: 24846f12-6d9e-4a04-b3bf-abb970710e00 Correlation ID: c0886b13-403b-4843-8fbe-34525d564452 Timestamp: 2024-04-30 02:15:00Z","error_codes":[65001],"timestamp":"2024-04-30 02:15:00Z","trace_id":"24846f12-6d9e-4a04-b3bf-abb970710e00","correlation_id":"c0886b13-403b-4843-8fbe-34525d564452","suberror":"consent_required"}"
  • I’m following this guide: https://learn.microsoft.com/en-us/graph/auth-v2-user?tabs=http
  • Scopes I’m requesting: offline_access User.Read Files.Read
  • My current set up works for generating the oauth url successfully per the guide, I see the scopes my app is requesting (User.Read, Files.Read, offline_access), I accept and am successfully redirected to a url containing the code, state, and session_state, however I get the invalid_grant error trying to generate the access token with the code returned from the oauth url flow following the specifications in the guide.
  • I’ve added the APIs I want and granted admin consent for the APIs I want for permissions for in Application > API permissions > Grant admin consent, I. have also added the User.Read and Files.Read scopes to the ‘Expore an API’ tab.
  • I can confirm the redirect uri, client secret, client id, and tenant ID being used in my code matches up to the values in the Azure UI
  • In the web app I created in App Registrations, under Authentication sidebar tab, the Implicit grant and hybrid flows checkboxes are unchecked, also ‘Allow public client flows’ setting is set to false.

It seems to me like I’m following the guide precisely, and there’s some issue in my Azure UI configuration somewhere that I don’t know about and that isn’t included in the guide. Any advice for resolving this issue would be much appreciated!

TLDR and main question, what is this error caused by when trying to generate an access token?

400 Bad Request: "{"error":"invalid_grant","error_description":"AADSTS65001: The user or administrator has not consented to use the application with ID 'fa30181d-73e3-4ac8-bc74-cdb9323c19f6' named 'appTesting'. Send an interactive authorization request for this user and resource. Trace ID: 24846f12-6d9e-4a04-b3bf-abb970710e00 Correlation ID: c0886b13-403b-4843-8fbe-34525d564452 Timestamp: 2024-04-30 02:15:00Z","error_codes":[65001],"timestamp":"2024-04-30 02:15:00Z","trace_id":"24846f12-6d9e-4a04-b3bf-abb970710e00","correlation_id":"c0886b13-403b-4843-8fbe-34525d564452","suberror":"consent_required"}"

As described in problem detail.

New contributor

Myles is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật