I am developing an Unity app for tablets in which our employees calendar info is collected from Microsoft Graph and shown on screen. But I'm having problems with logging in users to MS Graph without being redirected to using a web browser.
Currently I am connecting to our app's server endpoint through https://login.microsoftonline.com/tenant_id_here/oauth2/token , but I can't find a working way to login for a user, which is nessesary to ask for the calendar info.
The grant_type password from Flow 2 in this blog is supposed to do exactly this: http://codematters.tech/getting-access-token-for-microsoft-graph-using-oauth-rest-api/ However, using the grant_type password will always return an errorcode, even when the username & password is correct:
AADSTS70002: Error validating credentials. AADSTS50126: Invalid username or password
After searching answers, it appears that grant_type password has been put out of use: https://github.com/microsoftgraph/microsoft-graph-docs/issues/2657#issuecomment-390036447
If this is the case, how am I supposed to get a token for a user using username and password?
Now, I have indeed found a MS Graph SDK (https://github.com/microsoftgraph/msgraph-sdk-dotnet) which might solve this problem, but sadly it is running on a later version .NET that Unity does not support.
For reference, the app I'm trying to create will have a simple workflow like this:
User logs in through app and gets token > App asks Office365 for user calendar info using token > App displays calendar info, and refreshes token
Does anybody have an idea on how to do this?