sp-dev-docs
sp-dev-docs copied to clipboard
Is there a way to get access token of sharepoint user using credentials.
What type of issue is this?
Question
What SharePoint development model, framework, SDK or API is this about?
SharePoint REST API
Target SharePoint environment
SharePoint Online
What browser(s) / client(s) have you tested
- [ ] 💥 Internet Explorer
- [ ] 💥 Microsoft Edge
- [ ] 💥 Google Chrome
- [ ] 💥 FireFox
- [ ] 💥 Safari
- [ ] mobile (iOS/iPadOS)
- [ ] mobile (Android)
- [X] not applicable
- [ ] other (enter in the "Additional environment details" area below)
Additional environment details
- browser version
- SPFx version
- Node.js version
- etc
Issue description
I want to upload a file to user sharepoints account from my app using REST API for that i I need an accesstoken , is there a way to do it .
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Can you detail a bit more your scenario? you want to get a token from an SPFx Webpart? c# code in some backend app? there are different ways to get an access token to call SharePoint, but depends on the "client".
I want to upload a file from my springboot app to user's sharepoint account. I want to find a way to fetch the SP access token with the user's email and password.
Have a look to this sample using MSAL for Java. It´s about calling Graph API, but should be similar to call SharePoint, but changing how the Azure AD App is registered (configuring SP permissions). Also, have a look to Graph API, cos it have some endpoints to do things with SharePoint, so you might be fine with Graph.
https://github.com/Azure-Samples/ms-identity-msal-java-samples/tree/main/4.%20Spring%20Framework%20Web%20App%20Tutorial/2-Authorization-I/call-graph
If nothing helps, and considering you have user and pwd, you might use the Azure AD Resource owner flow described here: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth-ropc and just get a token calling the AAD Token endpoint sending user credentials. Please Note this flow is not recommended at all.