how to get current URl from Iframe

I have a requirement where i call api to extend the session , it’s a redirect Api which goes to IDP and IDP calls the rest api via iframe and then it calls the component where the iframe resides. If there is any error then we are passing queryParam “hasError” while calling component from backend. With in the component I am not able to look for queryParam . Can somebody please provide the guidance here :

this is my html : 
<iframe id='myIframe' hidden="hidden" (load)="onLoadIframe(iframe)" title="iframe-authn"></iframe>

this is my component : 

@Component({
    selector: "sso-authn",
    templateUrl: "./sso-authn.component.html"
})
export class SSOAuthNComponent implements AfterViewInit {
@Input()
public loadIframe: boolean;

constructor( @Inject('Window') private window: Window, private webhookServerConfigManager: WebhookServerConfigManager,private router: Router, private acRoute: ActivatedRoute) { }

    ngAfterViewInit() {
        if (this.loadIframe) {
            this.iframe = document.getElementById('myIframe');
            this.iframe.src= "http://localhost.com:4200/extend?goto=http://localhost.ukg.com:4200/sso-authn&realm=ok&compReq=ok;
        }
    }

    onLoadIframe(iframe: any) {
        **//tried to get url with this approach but it is returning parent window location href.**
        const iframeUrl = window.location.href;
  
        let queryParam = this.acRoute.snapshot.queryParams || {};
        if (iframeUrl && iframeUrl.indexOf("hasError") >= 0) {
            // Display session timeout page
            window.parent?.window?.postMessage({ "extendSession": false },     this.ServerConfigManager.ssoOrigin);
            // terminate session and redirect to error page
            console.log('error from auth',queryParam);
            window.parent?.window?.postMessage({ "extendSession": false, "error": queryParam }, this.ServerConfigManager.ssoOrigin);
             this.loadIframe = false;
        } else if (iframeUrl && iframeUrl.indexOf("hasSSO") >= 0) {
            console.log('success response');
            window.parent?.window?.postMessage({ "extendSession": true }, this.ServerConfigManager.ssoOrigin);
            this.loadIframe = false;
        }
    }
path to my component is :  {
    path:'sso-authn',
    component:SSOAuthNComponent
  }

# I want to access queryParam hasError from below url :
http://localhost.com:4200/sso-authn?hasSSO=true&realm=ok&hasError=QVVUSENPREVfSU5WQUxJRA%3D%3D