
JosephJ.99172 (Customer) asked a question.

We use cookies to provide the best website experience and to help understand marketing efforts. We may also share data with ad partners to reach potential customers across the web. To learn more, visit our Privacy Policy. Click here for Your Privacy Choices. You may also opt out of this sharing by signaling your preference via GPC, applicable only to the browser signaling the opt-out.
More information
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising.
Select All

We use cookies to provide the best website experience and to help understand marketing efforts. We may also share data with ad partners to reach potential customers across the web. To learn more, visit our Privacy Policy. Click here for Your Privacy Choices. You may also opt out of this sharing by signaling your preference via GPC, applicable only to the browser signaling the opt-out.
More information
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising.
Select All
Hi Joseph,
You can find here all the sample apps that we have for ASP.NET
https://github.com/okta?q=asp&type=&language=&sort=
Hi Tiberiu
Thanks for your reply. I am sorry, I couldn't sample to use OKTA for ASP.NET in Visual basic code. Can you please send me the sample or the link for it.
Thanks
Joseph
Hi Tiberiu
When I converted the Startup class from C# to VB, I got the following error message:
Severity Code Description Project File Line Suppression State
Error BC30516 Overload resolution failed because no accessible 'New' accepts this number of arguments. OKTA_DEMO C:\OKTA_DEMO\Startup.vb 42 Active
Severity Code Description Project File Line Suppression State
Error BC30456 'RequestAuthorizationCodeAsync' is not a member of 'TokenClient'. OKTA_DEMO C:\OKTA_DEMO\Startup.vb 43 Active
Severity Code Description Project File Line Suppression State
Warning BC42105 Function '<anonymous method>' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used. OKTA_DEMO C:\OKTA_DEMO\Startup.vb 56 Active
FOLLOWING IS THE FULL CONVERTED CODE:
Imports IdentityModel.Client
Imports Microsoft.AspNet.Identity
Imports Microsoft.IdentityModel.Protocols.OpenIdConnect
Imports Microsoft.IdentityModel.Tokens
Imports Microsoft.Owin
Imports Microsoft.Owin.Security
Imports Microsoft.Owin.Security.Cookies
Imports Microsoft.Owin.Security.OpenIdConnect
Imports Owin
Imports System
Imports System.Collections.Generic
Imports System.Configuration
Imports System.Security.Claims
Public Class Startup
Private ReadOnly _clientId As String = ConfigurationManager.AppSettings("okta:ClientId")
Private ReadOnly _redirectUri As String = ConfigurationManager.AppSettings("okta:RedirectUri")
Private ReadOnly _authority As String = ConfigurationManager.AppSettings("okta:OrgUri")
Private ReadOnly _clientSecret As String = ConfigurationManager.AppSettings("okta:ClientSecret")
Public Sub Configuration(ByVal app As IAppBuilder)
ConfigureAuth(app)
End Sub
Public Sub ConfigureAuth(ByVal app As IAppBuilder)
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie)
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType)
app.UseCookieAuthentication(New CookieAuthenticationOptions())
app.UseOpenIdConnectAuthentication(New OpenIdConnectAuthenticationOptions With {
.ClientId = _clientId,
.ClientSecret = _clientSecret,
.Authority = _authority,
.RedirectUri = _redirectUri,
.ResponseType = OpenIdConnectResponseType.CodeIdToken,
.Scope = OpenIdConnectScope.OpenIdProfile,
.TokenValidationParameters = New TokenValidationParameters With {
.NameClaimType = "name"
},
.Notifications = New OpenIdConnectAuthenticationNotifications With {
.AuthorizationCodeReceived = Async Function(n)
Dim tokenClient = New TokenClient($"{_authority}/v1/token", _clientId, _clientSecret)
Dim tokenResponse = Await tokenClient.RequestAuthorizationCodeAsync(n.Code, _redirectUri)
If tokenResponse.IsError Then
Throw New Exception(tokenResponse.[Error])
End If
Dim userInfoClient = New UserInfoClient($"{_authority}/v1/userinfo")
Dim userInfoResponse = Await userInfoClient.GetAsync(tokenResponse.AccessToken)
Dim claims = New List(Of Claim)(userInfoResponse.Claims) From {
New Claim("id_token", tokenResponse.IdentityToken),
New Claim("access_token", tokenResponse.AccessToken)
}
n.AuthenticationTicket.Identity.AddClaims(claims)
End Function
}
})
End Sub
End Class