Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors are not returned when application does not have the required scopes #32

Closed
arunpassi opened this issue Nov 29, 2021 · 6 comments
Closed
Assignees
Labels
question Further information is requested

Comments

@arunpassi
Copy link
Contributor

arunpassi commented Nov 29, 2021

I was trying this sdk to query groups. The Groups().Get() api fails and returns an empty set but err is not set.

       cred, err := azidentity.NewClientSecretCredential(
		<TenandID>,  // Removed for posting here
		<ClientID>,     // Removed for posting here
		<ClientSecret>, // Removed for posting here
		nil,
	)
	if err != nil {
		log.Printf("failed to get cred: %v\n", err)
		return err
	}

	auth, err := a.NewAzureIdentityAuthenticationProviderWithScopes(
		cred,
		[]string{"https://graph.microsoft.com/.default"},
	)
	if err != nil {
		log.Printf("failed to get identity: %v\n", err)
		return err
	}

	adapter, err := msgraphsdk.NewGraphRequestAdapter(auth)
	if err != nil {
		log.Printf("failed to get adapter: %v\n", err)
		return err
	}

	client := msgraphsdk.NewGraphServiceClient(adapter)
	result, err := client.Users().Get(nil)
	if err != nil {
		log.Printf("failed to get users: %v\n", err)
		return err
	}
        client := msgraphsdk.NewGraphServiceClient(adapter)

	resp, err := client.Groups().Get(nil)
	if err != nil {
		log.Printf("failed to get group: %v", err)
		return err
	}
       
       if (len(resp.GetValue()) == 0 {
                log.Printf("failed to get group")
       }

On debugging, I see http request failed with access denied as required scope for querying groups was not present. So error was returned in http request but was not propagated back to the caller.

On adding Directory.Read.All scope, it works fine and I get the groups. Problem is only not getting the error when it should be there.

@baywet
Copy link
Member

baywet commented Nov 29, 2021

Hi @arunpassi ,
Thanks for reaching out and trying out the SDK.

You are right, the errors returned by the API are currently not being deserialized, this is a limitation of the generator and I added this to the known limitations list (last point).

Also, looking at your example, you don't need to create a new client for each request, it can be reused. Let me know if you have other questions/concerns.

@baywet baywet self-assigned this Nov 29, 2021
@baywet baywet added Needs author feedback question Further information is requested labels Nov 29, 2021
@arunpassi
Copy link
Contributor Author

arunpassi commented Nov 29, 2021

Also, looking at your example, you don't need to create a new client for each request, it can be reused. Let me know if you have other questions/concerns.

Oh yes, that was a copy-paste mistake (pasted that line twice during an overlap).

@baywet
Copy link
Member

baywet commented Nov 29, 2021

Thanks. Closing this issue as it's a known limitation we're working on.

@baywet baywet closed this as completed Nov 29, 2021
@arunpassi
Copy link
Contributor Author

Hey @baywet , do you have any rough estimate by which this could be resolved?

@baywet
Copy link
Member

baywet commented Nov 29, 2021

This one is difficult to estimate since it has multiple layers of dependencies.
We definitively need to tackle it before the general availability of this sdk.
We're targeting a GA around May, but if course that all depends on the feedback we get in this preview as well as other priorities.
Keep using the sdk, the more usage and the more feedback we get, the faster it will GA.

@arunpassi
Copy link
Contributor Author

@baywet, thanks for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants