Authentication.GetExternalLoginInfoAsync() return null in case of HTTPS, but works fine in case of HTTP
Authentication.GetExternalLoginInfoAsync() return null in case of HTTPS, but works fine in case of HTTP
I issued a post request to my server from angular 6 @localhost:4200 while google/facebook authentication login =>
signupExternalUser(accesstoken) {
const httpOptions = {
headers: new HttpHeaders({
'content-type': 'application/JSON',
'Authorization': 'Bearer ' + accesstoken
})
};
this.http.post<any>('http://localhost:57310/api/Account/RegisterExternal',{}, httpOptions)
.subscribe((response: any) => {//do this;},(err: HttpErrorResponse) => { alert(err); })};
In WebAPI, I respond as =>
// POST api/Account/RegisterExternal
[OverrideAuthentication]
[HostAuthentication(DefaultAuthenticationTypes.ExternalBearer)]
[Route("RegisterExternal")]
public async Task<IHttpActionResult> RegisterExternal()
{
var info = await Authentication.GetExternalLoginInfoAsync();
if (info == null)
{
return InternalServerError();
}
var user = new ApplicationUser() { UserName = info.Email, Email = info.Email };
IdentityResult result = await UserManager.CreateAsync(user);
if (!result.Succeeded)
{
return GetErrorResult(result);
}
result = await UserManager.AddLoginAsync(user.Id, info.Login);
if (!result.Succeeded)
{
return GetErrorResult(result);
}
return Ok();
}
Now, I used here http://localhost:57310
for my server and google authentication works fine, although facebook doesn't support non-https uri. So, that's not an error.
http://localhost:57310
But, I changed to https://localhost:44305
for my server and both logins return error.
https://localhost:44305
Error is that, await Authentication.GetExternalLoginInfoAsync();
returns null.
await Authentication.GetExternalLoginInfoAsync();
I am using asp.net identity using owin-middleware in individual user account
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.