I am by all means a newbie to VB.net. I am seeking your help here.
I am writing a code to connect to REST API. I am having difficulties with passing one parameter to a function. Here is my code:
Dim AuthContext As New AuthenticationContext("https://login.microsoftonline.com/")
Dim ClientId As String = "f8f710b23-d3ea-4dd3-8a0e-c5958a6bc16d"
Dim RedirectUri As New Uri("ms-app://redirect/")
Dim ResourceIDUri As String = "https://analysis.windows.net/powerbi/api"
Dim AccessToken As String
Dim AuthHeader As String
Dim task1 As Task(Of AuthenticationResult) = AuthContext.AcquireTokenAsync(ResourceIDUri, ClientId, RedirectUri, New IPlatformParameters(PromptBehavior.Auto), New UserIdentifier("user1", 2))
and my issue is with the parameter (New IPlatformParameters(PromptBehavior.Auto)) as I get the following error:
'New' cannot be used on an interface
Here is the documentation for AccuireTokenSync
Can someone guide me to correct syntax of passing the parameter IPlatformParameters(PromptBehavior.Auto)
Do this:
result = await ac.AcquireTokenAsync("<clientId>", "https://resourceUrl", new Uri("https://ClientReplyUrl"), new PlatformParameters(PromptBehavior.Auto));
Here's a link to the ADAL .NET wiki which details how to use the PlatformParameters. 'parameters' of type 'PlatformParameters' is the ADAL.NET way of expressing what kind of interaction needs to happen with the user.
Auto the user is prompted for credentials only when needed.
Always the user is always prompted for credentials, even if a token exists in the cache, and if a user has a session. This is useful when the application wants to give the user an opportunity to sign-in with a different identity without giving any hint of previous identities.
RefreshSession the web browser is displayed, and the token gets updated claims. If the logon cookies are available (in the embedded web view) the user won't be prompted for credentials, and the dialog will quickly disappear (there will be a flash).
SelectAccount this shows a dialog containing the identities under which the user has currently sessions. The user can add other accounts.
Never [except on Android and iOS]: does not prompt the user for credentials.
CallerActivity [Android] or OwnerWindows [.NET 4.5] enable application developers to control what window/activity will be the parent of the authentication dialog. A developer might want to provide this parent information for UX reasons: to ensure that the dialog to appear centered on the parent window and over it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With