Forum Discussion

kirin519's avatar
kirin519
Copper Contributor
Apr 13, 2023

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

Replies have been turned off for this discussion
  • Muneeb07's avatar
    Muneeb07
    Copper 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 started :smile: with 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/.

     

    • kirin519's avatar
      kirin519
      Copper Contributor

      HiMuneeb07 , thanks for replying to me! Unfortunately, I am using three party provider(auto desk), which had nothing to do with Microsoft account, it doesn't need to use Microsoft account. What I know about MSAL was, it does not support non-Azure identity providers.

Resources