|
| 1 | +--- |
| 2 | +title: "RTCPeerConnection: idpLoginUrl property" |
| 3 | +short-title: idpLoginUrl |
| 4 | +slug: Web/API/RTCPeerConnection/idpLoginUrl |
| 5 | +page-type: web-api-instance-property |
| 6 | +browser-compat: api.RTCPeerConnection.idpLoginUrl |
| 7 | +--- |
| 8 | + |
| 9 | +{{APIRef("WebRTC")}} |
| 10 | + |
| 11 | +The **`idpLoginUrl`** read-only property of the {{domxref("RTCPeerConnection")}} interface returns a string containing the URL endpoint the application can open to log users in to the {{Glossary("Identity provider", "identity provider")}} (IdP). This value is `null` until the IdP indicates that login is needed. |
| 12 | + |
| 13 | +When a call to {{domxref("RTCPeerConnection.getIdentityAssertion()")}} fails because the IdP requires user authentication, the resulting promise is rejected with an {{domxref("RTCError")}} whose {{domxref("RTCError.errorDetail", "errorDetail")}} is `"idp-need-login"`. The browser then sets this property to the login URL provided by the IdP. The application can open this URL (for example, in a pop-up window or `<iframe>`) to allow the user to complete the login process before retrying the identity assertion. |
| 14 | + |
| 15 | +## Value |
| 16 | + |
| 17 | +A string containing the IdP login URL, or `null` if no login is needed. |
| 18 | + |
| 19 | +## Examples |
| 20 | + |
| 21 | +### Handling an IdP login requirement |
| 22 | + |
| 23 | +In this example, the application attempts to gather an identity assertion. If the IdP rejects the attempt because the user is not authenticated, the application opens the login URL provided in `idpLoginUrl`. |
| 24 | + |
| 25 | +```js |
| 26 | +const pc = new RTCPeerConnection(); |
| 27 | +pc.setIdentityProvider("login.example.com"); |
| 28 | + |
| 29 | +pc.getIdentityAssertion().catch((error) => { |
| 30 | + if (pc.idpLoginUrl) { |
| 31 | + console.log(`IdP login required at: ${pc.idpLoginUrl}`); |
| 32 | + // Open the login page in a popup window |
| 33 | + const loginWindow = window.open( |
| 34 | + pc.idpLoginUrl, |
| 35 | + "idp-login", |
| 36 | + "width=500,height=600", |
| 37 | + ); |
| 38 | + } else { |
| 39 | + console.error("Identity assertion failed:", error); |
| 40 | + } |
| 41 | +}); |
| 42 | +``` |
| 43 | + |
| 44 | +## Specifications |
| 45 | + |
| 46 | +{{Specifications}} |
| 47 | + |
| 48 | +## Browser compatibility |
| 49 | + |
| 50 | +{{Compat}} |
| 51 | + |
| 52 | +## See also |
| 53 | + |
| 54 | +- [WebRTC API](/en-US/docs/Web/API/WebRTC_API) |
| 55 | +- {{domxref("RTCPeerConnection.peerIdentity")}} |
| 56 | +- {{domxref("RTCPeerConnection.getIdentityAssertion()")}} |
| 57 | +- {{domxref("RTCPeerConnection.setIdentityProvider()")}} |
| 58 | +- {{domxref("RTCIdentityAssertion")}} |
0 commit comments