I'm trying to implement LinkedIn/OAuth authentication in my ASP.NET Core 2.0 app and I need to set the scope to { "r_basicprofile", "r_emailaddress" }
so that I can user's email, profile image, etc.
When I try to set the scope in the following code, I'm getting the following error:
Property or indexer 'OAuthOptions.Scope' cannot be assigned to -- it's read-only.
Here's the code:
services.AddOAuth(CookieAuthenticationDefaults.AuthenticationScheme, options => {
options.SignInScheme = "LinkedIn";
options.ClientId = "1234567890";
options.ClientSecret = "1234567890";
options.CallbackPath = "/linkedin-callback";
// Configure the LinkedIn endpoints
options.AuthorizationEndpoint = "https://www.linkedin.com/oauth/v2/authorization",
options.TokenEndpoint = "https://www.linkedin.com/oauth/v2/accessToken",
options.UserInformationEndpoint = "https://api.linkedin.com/v1/people/~:(id,first-name,last-name,email-address,picture-url,picture-urls::(original))",
options.Scope = { "r_basicprofile", "r_emailaddress" };
options.Events = new OAuthEvents
{
OnCreatingTicket = OnCreatingTicketLinkedInCallBack,
OnTicketReceived = OnTicketReceivedCallback
};
})
Any idea how I can set the scope?
P.S. I tried to adapt the code from my ASP.NET Core 1.1. This code was working fine in the ASP.NET Core 1.1 app.