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

Integration with Graph SDK from Java is very unclear #2180

Open
diyoyo opened this issue Sep 16, 2024 · 2 comments
Open

Integration with Graph SDK from Java is very unclear #2180

diyoyo opened this issue Sep 16, 2024 · 2 comments
Labels
Enhancement This is a feature request to add functionality that is not currently supported

Comments

@diyoyo
Copy link

diyoyo commented Sep 16, 2024

As someone very well stated here,
while the sample code for authentication from Android works perfectly fine, it is very unclear how to combine this with the Graph SDK, and especially the creation of the GraphServiceClient

How do we create a new instance of GraphServiceClient (Or how to get a AuhtenticationProvider like AzureIdentityAuthenticationProvider) from IAuthenticationResult or ISingleAccountPublicClientApplication or IAccount ?

@negoe negoe added the Enhancement This is a feature request to add functionality that is not currently supported label Oct 30, 2024
@negoe
Copy link
Contributor

negoe commented Oct 30, 2024

Hi @diyoyo, Thanks a lot for feedback. I will consider your request and work with my team in near future to provide guidance for working MSAL in combination with Graph SDK. Thanks for your patience.

@slowcar
Copy link

slowcar commented Nov 25, 2024

We use a BaseBearerTokenAuthenticationProvider to create a GraphServiceClient(authProvider, okHttpClient) object.
You have to substitute the "getToken()" call with your graph token - we keep ours in a cache and otherwise call aquireTokenSilent on the IMultipleAccountPublicClientApplication.

BaseBearerTokenAuthenticationProvider authProvider = new BaseBearerTokenAuthenticationProvider(new AccessTokenProvider() {
	@NonNull
	@Override
	public String getAuthorizationToken(@NonNull URI uri, Map<String, Object> additionalAuthenticationContext) {
		return getToken();
	}

	@NonNull
	@Override
	public AllowedHostsValidator getAllowedHostsValidator() {
		//list of allowed hosts from AzureIdentityAccessTokenProvider
		return new AllowedHostsValidator("graph.microsoft.com", "graph.microsoft.us", "dod-graph.microsoft.us", "graph.microsoft.de", "microsoftgraph.chinacloudapi.cn", "canary.graph.microsoft.com");
	}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement This is a feature request to add functionality that is not currently supported
Projects
None yet
Development

No branches or pull requests

3 participants