0
wksoftwareconsulting created
Hello we are trying to implment classlink login integration. So if user click on class link button they get authenticated and then our backend get login info which user is logged in. with code below it shows class link button and on click it redirect user to class link page and user get logged in but after that it again go back to class link page something wrong .. can you help me to make it working...
https://developer.classlink.com/docs/oauth2-workflow
I added following code to try to make it run Rhithm.Web.Host\Startup\RhithmWebHostModule.cs
if (bool.Parse(_appConfiguration["Authentication:ClassLink:IsEnabled"]))
{
externalAuthConfiguration.Providers.Add(
new ExternalLoginProviderInfo(
"ClassLink",
_appConfiguration["Authentication:ClassLink:ClientId"],
_appConfiguration["Authentication:ClassLink:ClientSecret"],
typeof(OAuth2ConnectAuthProviderApi),
new Dictionary<string, string>
{
{"Authority", _appConfiguration["Authentication:ClassLink:Authority"]},
{"LoginUrl",_appConfiguration["Authentication:ClassLink:LoginUrl"]},
{"ValidateIssuer",_appConfiguration["Authentication:ClassLink:ValidateIssuer"]}
}
)
);
}
Rhithm.Web.Host\Startup\AuthConfigurer.cs
if (bool.Parse(configuration["Authentication:ClassLink:IsEnabled"]))
{
authenticationBuilder.AddOAuth("ClassLink", options =>
{
options.ClientId = configuration["Authentication:ClassLink:ClientId"];
options.ClientSecret = configuration["Authentication:ClassLink:ClientSecret"];
options.CallbackPath = new PathString("/classLink/GetTokenInfoAsync");
options.AuthorizationEndpoint = "https://launchpad.classlink.com/oauth2/v2/auth";
options.TokenEndpoint = "https://launchpad.classlink.com/oauth2/v2/token";
options.UserInformationEndpoint = "https://nodeapi.classlink.com/v2/my/info";
options.Scope.Add("full");
options.SaveTokens = true;
options.Events = new OAuthEvents
{
OnCreatingTicket = async context =>
{
var request = new HttpRequestMessage(HttpMethod.Get, context.Options.UserInformationEndpoint);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", context.AccessToken);
var response = await context.Backchannel.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, context.HttpContext.RequestAborted);
response.EnsureSuccessStatusCode();
var user = JObject.Parse(await response.Content.ReadAsStringAsync());
context.RunClaimActions(user);
}
};
});
}
\angular\src\account\login\login.service.ts
private getClasslinkConnectConfig(loginProvider: ExternalLoginProvider): any {
debugger;
let authConfig = new AuthConfig();
authConfig.loginUrl = loginProvider.additionalParams['LoginUrl'];
authConfig.issuer = loginProvider.additionalParams['Authority'];
authConfig.skipIssuerCheck = loginProvider.additionalParams['ValidateIssuer'] === 'false';
authConfig.clientId = loginProvider.clientId;
authConfig.responseType = 'code';
authConfig.redirectUri = window.location.origin + '/account/login';
authConfig.scope = 'full';
authConfig.requestAccessToken = true;
return authConfig;
}
2 Answer(s)
-
0
-
0
This issue is closed because it has not had recent activity for a long time.
Have an answer to this question?
Log in
and write your answer.