connect to fabric database using jdbc and oauth

Ben or 0 Reputation points
2024-10-28T12:03:14.02+00:00

Hi, after successfully connection using oauth flow and reciveing a token for scope  https://analysis.windows.net/powerbi/api/Warehouse.ReadWrite.All using my access code I can get a refresh code and using that refresh code I can get multiple access codes so that session is working fine and the code is also working to connect to snowflake using azure so I don't think the error is on that side once I use the same connection for I get  "The TCP/IP connection to the host pbipwus9-westus.pbidedicated.windows.net<some id> (redirected from <same some id>.datawarehouse.fabric.microsoft.com), port 1433 has failed. Error: "null. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall."."

the connection properties are accessToken, encrypt=true trustServerCertificate=true and connection string jdbc:sqlserver://<SQL connection string> taken from the UI 

benor1470_0-1725182501616.png

I'm getting an error saying
"Login failed due to invalid authentication methods."

what am I doing wrong?
attached my java code as Main.txt

tried other scopes as
https://analysis.windows.net/powerbi/api/Warehouse.ReadWrite.All https://analysis.windows.net/powerbi/api/Connection.Read.All https://sql.azuresynapse-dogfood.net/user_impersonation
non of them works

Azure Service Fabric
Azure Service Fabric
An Azure service that is used to develop microservices and orchestrate containers on Windows and Linux.
272 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sina Salam 14,626 Reputation points
    2024-10-28T14:26:40.6+00:00

    Hello Ben or,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you are having 'the TCP/IP connection to the host pbipwus9-westus.pbidedicated.windows.net<some id> (redirected from <same some id>.datawarehouse.fabric.microsoft.com), port 1433 has failed. Error:' while working in your fabric database.

    To resolve the issue:

    This links will provide you a detailed steps to resolve it.

    To troubleshoot further, you can take a few additional steps: First, check the token validity by using a tool like JWT.io to decode your token and verify its claims and expiration. Next, ensure that your local machine or network firewall is not blocking outbound connections to the SQL Server. Finally, make sure your JDBC connection string is correctly formatted, which should look something like this: String connectionUrl = "jdbc:sqlserver://<SQL connection string>;encrypt=true;trustServerCertificate=true;accessToken=<your_access_token>";.

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.


  2. Chandra Boorla 5,835 Reputation points Microsoft Vendor
    2024-10-28T14:29:12.02+00:00

    Hi @Ben or

    Greetings & Welcome to Microsoft Q&A forum! Thanks for posting your query!

    MS Fabric is currently not supported in the Q&A forums, the supported products are listed over here Supported products on MS Q&A (more to be added later on).

    You can ask the experts in the dedicated MS Fabric community forum.

    Can you please open as a new thread in MS Fabric community: https://community.fabric.microsoft.com/t5/General-Discussion/bd-p/ac_generaldiscussion

    User's image I hope this information helps. Please do let us know if you have any further queries.

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    Thank you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.