简体   繁体   中英

WsTrust endpoint not found in metadata document

I am following this tutorial to learn how to get token after user successful login.

Steps I have done so far:

  1. I have registered myself(username and password) using this URL : https://MyCompany.b2clogin.com/MyCompany.onmicrosoft.com/oauth2/v2.0/authorize?p=B2C_1_ApplicantSignInSignUp&client_id=some-client-id&nonce=defaultNonce&redirect_uri=https%3A%2F%2Flocalhost&scope=openid&response_type=id_token&response_mode=query

  2. In the above example I have given AUTHORITY as " https://login.microsoftonline.com/MyCompany.onmicrosoft.com/ " or " https://MyCompany.b2clogin.com/tfp/MyCompany.onmicrosoft.com/B2C_1_ApplicantSignInSignUp "

  3. Client Id which I have received from the registration url in Step 1.

After running the code i see get the error for AUTHORITY as " https://login.microsoftonline.com/MyCompany.onmicrosoft.com/ ":

    Caused by: com.microsoft.aad.adal4j.AuthenticationException: WsTrust endpoint not found in metadata document
at com.microsoft.aad.adal4j.WSTrustRequest.execute(WSTrustRequest.java:85)
at com.microsoft.aad.adal4j.AcquireTokenCallable.processPasswordGrant(AcquireTokenCallable.java:137)
at com.microsoft.aad.adal4j.AcquireTokenCallable.execute(AcquireTokenCallable.java:60)
at com.microsoft.aad.adal4j.AcquireTokenCallable.execute(AcquireTokenCallable.java:38)
at com.microsoft.aad.adal4j.AdalCallable.call(AdalCallable.java:47)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)

And get different error when I set AUTHORITY as " https://MyCompany.b2clogin.com/tfp/MyCompany.onmicrosoft.com/B2C_1_ApplicantSignInSignUp "

Caused by: com.microsoft.aad.adal4j.AuthenticationException: Server returned HTTP response code: 404 for URL : https://mycompany.b2clogin.com/common/userrealm/sumantapakira@gmail.com?api-version=1.0, Error details : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

The error occured while executing this part of the code:

    Future<AuthenticationResult> future = context.acquireToken(
                "https://graph.microsoft.com", CLIENT_ID, username, password, null);

I am not sure what I am doing wrong, is it AUTHORITY URL is not correct or client id is not correct. I am using the same username/password which I had used during registration in Step #1

Many thanks for your help

Please ensure that you are using your global tenant admin account, which is your .onmicrosoft.com account. This error usually occurs if you are using the wrong credentials.

Your Client ID will match your application ID, as these are synonymous. So these need to be the same in your app registration and in your code. (This applies to your authority URL as well.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM