Forum Discussion
Oauth 2.0 authentication in Hololens
Hi Developers, I am trying to insert OAuth 2.0 function into my application inside the HoloLens, but haven't found a successful way for the past two weeks. I had try using Launcher function like LaunchUri, I was able to do all the login authentication with the edge it pop out but was not able to return any information from it to my application. I also try to use web authentication broker(WAB) but was keep giving me error "Value does not fall within expected range". I was able to do it in a desktop application, but not in HoloLens. Can anyone give me some suggestion on what I can do?
So my steps are
Step 1: Direct the User to the Authorization Web Flow
which is to launch a website for authorization through a provider
Step 2 : When consent has been granted, the user will be redirected back to your callback URL (redirect_uri) with an additional code query parameter that contains the authorization code
Thanks!!!!!!!
2 Replies
- Muneeb07Copper Contributor
One potential solution is to use the Microsoft Authentication Library (MSAL) for authentication and authorization in your application. MSAL provides a set of libraries and APIs that make it easier to integrate with OAuth 2.0 and OpenID Connect providers like Azure AD.
To get started with MSAL, you can follow these steps:
Install the MSAL NuGet package in your HoloLens project.
Create an instance of the PublicClientApplication class, which represents your application's connection to the authentication service.
scss
Copy code
IPublicClientApplication app = PublicClientApplicationBuilder
.Create(clientId)
.WithAuthority(authority)
.Build();
Call the AcquireTokenInteractive method to initiate the authentication flow.
csharp
Copy code
var scopes = new string[] { "user.read" };
var result = await app.AcquireTokenInteractive(scopes).ExecuteAsync();
This will launch a browser window on the HoloLens, allowing the user to authenticate and authorize your application.
Once the user has granted consent, the authentication result will contain an access token that you can use to access protected resources.
c
https://www.allminecraftapk.com/
string accessToken = result.AccessToken;
With MSAL, you can also handle refresh tokens and other authentication scenarios, such as using client credentials or device code authentication.
I hope this helps you get startedwith integrating OAuth 2.0 into your HoloLens application. If you continue to experience issues, it may be helpful to consult the MSAL documentation or reach out to Microsoft support for further assistance http://allminecraftapk.com/.