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

How to get authenticationProvider with new azure-sdk-for-java OAuth2AuthorizedClient #793

Closed
mattstrain opened this issue Jun 8, 2021 · 2 comments
Assignees

Comments

@mattstrain
Copy link

mattstrain commented Jun 8, 2021

With the azure-sdk-for-java you can now obtain authorisation tokens for clients and on behalf of users as part of the API like this.

public String callGraph(@RegisteredOAuth2AuthorizedClient("graph") OAuth2AuthorizedClient graph) {
  
if (null != graph) {
            String body = webClient
                .get()
                .uri(GRAPH_ME_ENDPOINT)
                .attributes(oauth2AuthorizedClient(graph))
                .retrieve()
                .bodyToMono(String.class)
                .block();
            LOGGER.info("Response from Graph: {}", body);
            return "Graph response " + (null != body ? "success." : "failed.");
        } else {
            return "Graph response failed.";
        }
}

However all the samples there don't use this API and just call the api directly using a webclient. See azure-spring-boot-sample-active-directory-resource-server-obo

How do we build a GraphService client using this API from a OAuth2AuthorizedClient object?
AB#9805

@ghost ghost added the ToTriage label Jun 8, 2021
@baywet
Copy link
Member

baywet commented Jun 8, 2021

Hey @mattstrain ,
Thanks for reaching out. Right now OBO is not supported by azure identity java and we have an issue tracking this here.

The workarounds include using MSAL or relying on frameworks/libraries (like spring) to "trade" the token for your application. Once this is done, you can derive from BaseAuthenticationProvider to pass the new token to the graph client.
Let me know if you have further questions.

@baywet baywet self-assigned this Jun 8, 2021
@ghost ghost removed the ToTriage label Jun 8, 2021
@ghost ghost removed the ToTriage label Jun 8, 2021
@mattstrain
Copy link
Author

Great thanks for the update. I'll keep an eye on that issue for updates.

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

No branches or pull requests

2 participants