Facing issues to connect with synapse workspace/azure sql db via oauth

SUBHAM KUMAR 0 Reputation points
2024-07-15T05:04:01.89+00:00

I want to connect to and access my Synapse Workspace and SQL Pool using OAuth. For this purpose, I have created an app in Azure and assigned the following API permissions:

  1. Microsoft Graph:
    • Directory.Read.All (Delegated)
    • Directory.ReadWrite.All (Delegated)
    • Directory.AccessAsUser.All (Delegated)
    • User.Read
    • User.Read.All
    • User.ReadWrite
  2. Azure Storage:
    • user_impersonation (Delegated)
  3. Azure SQL Database:
    • user_impersonation (Delegated)

I am requesting access tokens with the following parameters:

  • Authorization URL: https://login.microsoftonline.com/<tenant-id>/oauth2/authorize
  • Token URL: https://login.microsoftonline.com/<tenant-id>/oauth2/token
  • Scope:
  • https://graph.microsoft.com/.default
  • https://management.azure.com/.default
    • https://storage.azure.com/user_impersonation
    • https://sql.azuresynapse-dogfood.net/user_impersonation

With these parameters, I am able to obtain access tokens. However, when I use these access tokens to connect to my Synapse Workspace and Azure SQL Database via SQLServerDriver with the connection property accessToken set to the fetched access token value, I receive the following error:
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user '<token-identified principal>'. Incorrect or invalid token.

I would like to add that with username and password i could connect to workspace and sql pool so we can rule out connectivity issues

Azure SQL Database
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,003 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,012 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

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.