Hi @Martin,
Thank you for posting your question in the Microsoft Q&A forum.
Based on the information you have provided, it looks like you have problem with OneDrive File Picker.
This is my suggestion code, you could try to run this to see if it works.
// Ensure OneDrive SDK v7.2 is loaded:
// <script type="text/javascript" src="https://js.live.net/v7.2/OneDrive.js"></script>
function launchOneDrivePicker(accessToken, clientId) {
if (!accessToken || !clientId) {
console.error("OneDrive Picker: Missing access token or client ID.");
return;
}
const pickerOptions = {
clientId: clientId,
action: "query", // Or "download", "pick", "save"
multiSelect: false,
advanced: {
accessToken: accessToken, // Key for v7.2
// Recommended if your token is for MS Graph:
endpointHint: "https://graph.microsoft.com/v1.0/",
},
success: function(files) {
console.log("Picker success:", files.values);
if (files.values && files.values.length > 0) {
// Example: Process the first selected file
const file = files.values[0];
console.log("Selected:", file.name, file.id);
// Access download URL if available, e.g., file["@microsoft.graph.downloadUrl"]
}
},
cancel: function() {
console.log("Picker cancelled by user.");
},
error: function(error) {
console.error("Picker error:", error);
// Troubleshoot: Check token validity (scopes, audience, expiry), clientId, and endpointHint.
}
};
OneDrive.open(pickerOptions);
}
/*
// --- How to use (example): ---
// const userToken = "YOUR_VALID_MS_GRAPH_ACCESS_TOKEN";
// const appId = "YOUR_AZURE_APP_CLIENT_ID";
// launchOneDrivePicker(userToken, appId);
// --- Critical Reminders (Not in the code, but for you): ---
// 1. Access Token MUST be valid:
// - For MS Graph (https://graph.microsoft.com/).
// - Correct scopes (e.g., Files.Read.All, Files.ReadWrite.All).
// - Not expired.
// 2. `clientId` must match the one used to get the token.
//
// If login prompts persist, the token is likely the issue.
// Test token directly against MS Graph API first.
*/
I hope this information helps.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.