SOLVED

Graph API access without using client id and secret key

Copper Contributor

I have a C# Application that reads O365 groups and teams Information using graph API and generates a report. I am able to read and write teams info using graph API by authenticating using tenant info, client id and secret key (these values come from Azure APP registration). I am trying to avoid this App Registration step(tool requires client id and user login to get information). Is there any possible way to do authentication without client id?(like graph explorer does)

https://docs.microsoft.com/en-us/graph/sdks/choose-authentication-providers?tabs=CS

Above auth provider link doesn't have any authentication without clientid.

Authentication used in the tool:

static String[] sca = { "https://graph.microsoft.com/.default" };

var auth = PublicClientApplicationBuilder
.Create(clientid)
.WithTenantId(tenantid)
.Build();
InteractiveAuthenticationProvider authProvider = new InteractiveAuthenticationProvider(auth , sca);

 

 

3 Replies
best response confirmed by ThereseSolimeno (Microsoft)
Solution

Well you are the one deciding what type of authentication the application will use, if you want it to run in a user context simply switch to the corresponding mode. Do note that the permissions of the current user will apply for any queries you run via the app in such scenario, so you will only get access to groups/teams the user is a member of.

@User1_Infosys 

 

Accessing Graph API requires App Registration on Azure AD. Graph Explorer is also registered as an enterprise application on Azure AD.

var powerShellClientId = "1950a258-227b-4e31-a9cf-717495945fc2"; // use this one
IPublicClientApplication appDp = PublicClientApplicationBuilder
.Create(powerShellClientId)
.WithTenantId(tenantId)
.WithRedirectUri("https://login.microsoftonline.com/common/oauth2/nativeclient")
.WithDesktopFeatures()
.Build();
var scope = new string[] { "https://graph.microsoft.com/.default" };

var authToken = await appDp.AcquireTokenInteractive(scope)
.ExecuteAsync();
1 best response

Accepted Solutions
best response confirmed by ThereseSolimeno (Microsoft)
Solution

Well you are the one deciding what type of authentication the application will use, if you want it to run in a user context simply switch to the corresponding mode. Do note that the permissions of the current user will apply for any queries you run via the app in such scenario, so you will only get access to groups/teams the user is a member of.

View solution in original post