azure-docs-sdk-java/docs-ref-autogen/com.azure.identity.Interact...

76 строки
11 KiB
YAML

### YamlMime:JavaType
uid: "com.azure.identity.InteractiveBrowserCredential"
fullName: "com.azure.identity.InteractiveBrowserCredential"
name: "InteractiveBrowserCredential"
nameWithType: "InteractiveBrowserCredential"
summary: "Interactive browser authentication is a type of authentication flow offered by [Microsoft Entra ID][] that enables users to sign in to applications and services using a web browser.\n\n\n[Microsoft Entra ID]: https://learn.microsoft.com/entra/fundamentals/"
inheritances:
- "<xref href=\"java.lang.Object?displayProperty=fullName\" data-throw-if-not-resolved=\"False\" />"
inheritedClassMethods:
- classRef: "java.lang.<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>"
methodsRef:
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--\">clone</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-\">equals</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--\">finalize</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--\">getClass</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--\">hashCode</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--\">notify</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--\">notifyAll</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--\">toString</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-\">wait</a>"
syntax: "public class **InteractiveBrowserCredential**</br> implements <xref href=\"com.azure.core.credential.TokenCredential?alt=com.azure.core.credential.TokenCredential&text=TokenCredential\" data-throw-if-not-resolved=\"False\" />"
methods:
- uid: "com.azure.identity.InteractiveBrowserCredential.authenticate()"
fullName: "com.azure.identity.InteractiveBrowserCredential.authenticate()"
name: "authenticate()"
nameWithType: "InteractiveBrowserCredential.authenticate()"
summary: "Interactively authenticates a user via the default browser."
syntax: "public Mono<AuthenticationRecord> authenticate()"
desc: "Interactively authenticates a user via the default browser. This method will always generate a challenge to the user."
returns:
description: "The <xref uid=\"com.azure.identity.AuthenticationRecord\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AuthenticationRecord\"></xref> which can be used to silently authenticate the account\n on future execution if persistent caching was enabled via\n <xref uid=\"com.azure.identity.InteractiveBrowserCredentialBuilder.tokenCachePersistenceOptions(com.azure.identity.TokenCachePersistenceOptions)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"InteractiveBrowserCredentialBuilder#tokenCachePersistenceOptions(TokenCachePersistenceOptions)\"></xref>\n when credential was instantiated."
type: "<a href=\"https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html\">Mono</a>&lt;<xref href=\"com.azure.identity.AuthenticationRecord?alt=com.azure.identity.AuthenticationRecord&text=AuthenticationRecord\" data-throw-if-not-resolved=\"False\" />&gt;"
- uid: "com.azure.identity.InteractiveBrowserCredential.authenticate(com.azure.core.credential.TokenRequestContext)"
fullName: "com.azure.identity.InteractiveBrowserCredential.authenticate(TokenRequestContext request)"
name: "authenticate(TokenRequestContext request)"
nameWithType: "InteractiveBrowserCredential.authenticate(TokenRequestContext request)"
summary: "Interactively authenticates a user via the default browser."
parameters:
- description: "The details of the authentication request."
name: "request"
type: "<xref href=\"com.azure.core.credential.TokenRequestContext?alt=com.azure.core.credential.TokenRequestContext&text=TokenRequestContext\" data-throw-if-not-resolved=\"False\" />"
syntax: "public Mono<AuthenticationRecord> authenticate(TokenRequestContext request)"
desc: "Interactively authenticates a user via the default browser. This method will always generate a challenge to the user."
returns:
description: "The <xref uid=\"com.azure.identity.AuthenticationRecord\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AuthenticationRecord\"></xref> which can be used to silently authenticate the account\n on future execution if persistent caching was configured via\n <xref uid=\"com.azure.identity.InteractiveBrowserCredentialBuilder.tokenCachePersistenceOptions(com.azure.identity.TokenCachePersistenceOptions)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"InteractiveBrowserCredentialBuilder#tokenCachePersistenceOptions(TokenCachePersistenceOptions)\"></xref>\n when credential was instantiated."
type: "<a href=\"https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html\">Mono</a>&lt;<xref href=\"com.azure.identity.AuthenticationRecord?alt=com.azure.identity.AuthenticationRecord&text=AuthenticationRecord\" data-throw-if-not-resolved=\"False\" />&gt;"
- uid: "com.azure.identity.InteractiveBrowserCredential.getToken(com.azure.core.credential.TokenRequestContext)"
fullName: "com.azure.identity.InteractiveBrowserCredential.getToken(TokenRequestContext request)"
name: "getToken(TokenRequestContext request)"
nameWithType: "InteractiveBrowserCredential.getToken(TokenRequestContext request)"
parameters:
- name: "request"
type: "<xref href=\"com.azure.core.credential.TokenRequestContext?alt=com.azure.core.credential.TokenRequestContext&text=TokenRequestContext\" data-throw-if-not-resolved=\"False\" />"
syntax: "public Mono<AccessToken> getToken(TokenRequestContext request)"
returns:
type: "<a href=\"https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html\">Mono</a>&lt;<xref href=\"com.azure.core.credential.AccessToken?alt=com.azure.core.credential.AccessToken&text=AccessToken\" data-throw-if-not-resolved=\"False\" />&gt;"
- uid: "com.azure.identity.InteractiveBrowserCredential.getTokenSync(com.azure.core.credential.TokenRequestContext)"
fullName: "com.azure.identity.InteractiveBrowserCredential.getTokenSync(TokenRequestContext request)"
name: "getTokenSync(TokenRequestContext request)"
nameWithType: "InteractiveBrowserCredential.getTokenSync(TokenRequestContext request)"
parameters:
- name: "request"
type: "<xref href=\"com.azure.core.credential.TokenRequestContext?alt=com.azure.core.credential.TokenRequestContext&text=TokenRequestContext\" data-throw-if-not-resolved=\"False\" />"
syntax: "public AccessToken getTokenSync(TokenRequestContext request)"
returns:
type: "<xref href=\"com.azure.core.credential.AccessToken?alt=com.azure.core.credential.AccessToken&text=AccessToken\" data-throw-if-not-resolved=\"False\" />"
type: "class"
desc: "Interactive browser authentication is a type of authentication flow offered by [Microsoft Entra ID][] that enables users to sign in to applications and services using a web browser. With interactive browser authentication, the user is directed to a sign-in webpage and is prompted to enter their credentials. After the user successfully authenticates, Microsoft Entra ID issues a security token that the application can use to authorize the user's access to its resources. For more information refer to the [interactive browser authentication documentation][].\n\n**Required configuration:**\n\nTo use InteractiveBrowserCredential, you need to register an application in Microsoft Entra ID with permissions to log in on behalf of a user. Follow the steps below to configure your registered application.\n\n1. Go to Microsoft Entra ID in Azure portal and find your app registration.\n2. Navigate to the Authentication section.\n3. Under Suggested Redirected URIs, check the URI that ends with /common/oauth2/nativeclient.\n4. Under Authentication->Advanced settings, enable \"Allow public client flows.\"\n\nThese steps will let the application authenticate, but it still won't have permission to log you into Active Directory, or access resources on your behalf. To address this issue, navigate to API Permissions, and enable Microsoft Graph and the resources you want to access, such as Azure Service Management, Key Vault, and so on. You also need to be the admin of your tenant to grant consent to your application when you log in for the first time. In <xref uid=\"com.azure.identity.InteractiveBrowserCredentialBuilder.redirectUrl(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"InteractiveBrowserCredentialBuilder#redirectUrl(String)\"></xref>, a redirect URL can be specified. It configures the Redirect URL where STS will callback the application with the security code. It is required if a custom client id is specified via <xref uid=\"com.azure.identity.InteractiveBrowserCredentialBuilder.clientId(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"InteractiveBrowserCredentialBuilder#clientId(String)\"></xref> and must match the redirect URL specified during the application registration. You can add the redirect URL to the Redirect URIs subsection under the Authentication section of your registered Microsoft Entra application.\n\n**Sample: Construct InteractiveBrowserCredential**\n\nThe following code sample demonstrates the creation of a <xref uid=\"com.azure.identity.InteractiveBrowserCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.identity.InteractiveBrowserCredential\"></xref>, using the <xref uid=\"com.azure.identity.InteractiveBrowserCredentialBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.identity.InteractiveBrowserCredentialBuilder\"></xref> to configure it. By default, the credential targets a localhost redirect URL, to override that behaviour a <xref uid=\"com.azure.identity.InteractiveBrowserCredentialBuilder.redirectUrl(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"InteractiveBrowserCredentialBuilder#redirectUrl(String)\"></xref> can be optionally specified. Once this credential is created, it may be passed into the builder of many of the Azure SDK for Java client builders as the 'credential' parameter.\n\n```java\nTokenCredential interactiveBrowserCredential = new InteractiveBrowserCredentialBuilder().redirectUrl(\n \"http://localhost:8765\").build();\n```\n\n\n[Microsoft Entra ID]: https://learn.microsoft.com/entra/fundamentals/\n[interactive browser authentication documentation]: https://aka.ms/azsdk/java/identity/interactivebrowsercredential/docs"
implements:
- "<xref href=\"com.azure.core.credential.TokenCredential?alt=com.azure.core.credential.TokenCredential&text=TokenCredential\" data-throw-if-not-resolved=\"False\" />"
metadata: {}
package: "com.azure.identity"
artifact: com.azure:azure-identity:1.14.1