Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, August 3, 2017 11:51 AM
I want to get Access Token in SPFX solution but i didn't get any clue on that.
How can i do it?
All replies (3)
Friday, August 4, 2017 2:41 AM
Hi,
As per my knowledge, spfx running under the users context and can do whatever the user are allowed to do, so may I know why you need get Access Token?
You could check more details below.
https://github.com/SharePoint/sp-dev-docs/blob/master/docs/spfx/enterprise-guidance.md
If you want to call Microsoft Graph api, you could use ADAL to authenticate using the OAuth flow.
You could check below link for details.
Best Regards,
Lee
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected]
Tuesday, August 8, 2017 2:52 PM
Hi Lee,
Thanks for your answer.
What i want is i want to get TenantID by calling api 'https://xyz.sharepoint.com/_vti_bin/client.svc'.
But its not safe because as an anonymous user i can get tenantID by calling this api but it will gives 401 unauthorized status.
I want to call this API with AccessToken so it will provide status 200 if user is valid.
This is my requirement to get Access Token.
I refer your links but i think it will not help.
Do you have any better solution for this?
Thanks.
Monday, August 14, 2017 10:22 AM
Hi,
Below endpoint is public so you could use for anonymous users.
https://login.microsoftonline.com/yourtenant.onmicrosoft.com/.well-known/openid-configuration
Or, you could try to check whether current user is anonymous user, if anonymous user, skip to get tenantID.
Here are some links for your reference:
Best Regards,
Lee
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected]