Authenticate using IAuthenticationProvider

Mohamed Rafiudeen :

I'm trying to get a meeting details of a Microsoft Office account. I tried to use the below code

IAuthenticationProvider authProvider = (IAuthenticationProvider) new UsernamePasswordProvider(
    "7d06733e-766f-4c63-846c-5b3825b2d638",
    Arrays.asList("https://graph.microsoft.com/Calender.Read"),
    "[email protected]",
    "*******",
    NationalCloud.Global,
    "0df3f88a-c04e-40ac-8d41-84dbfb9e24d6",
    "*****");

I don't know why I'm getting below error:

The type com.microsoft.graph.httpcore.IAuthenticationProvider cannot be resolved. It is indirectly referenced from required .class files

my pom dependencies look like this:

<dependency>
    <groupId>com.microsoft.graph</groupId>
    <artifactId>microsoft-graph-core</artifactId>
    <version>1.0.0</version>
</dependency>
<dependency>
    <groupId>com.microsoft.graph</groupId>
    <artifactId>microsoft-graph</artifactId>
    <version>1.5.0</version>
</dependency>
<dependency>
    <groupId>com.microsoft.graph</groupId>
    <artifactId>microsoft-graph-auth</artifactId>
    <version>0.1.0-SNAPSHOT</version>
</dependency>

My code:

public class MicrosoftGraphHelper
{
    public static void main(String[] args)
    {
        IAuthenticationProvider authProvider = (IAuthenticationProvider) new UsernamePasswordProvider(
            "7d06733e-766f-4c63-846c-5b3825b2d638",
            Arrays.asList("https://graph.microsoft.com/Calender.Read"),
            "[email protected]",
            "*******",
            NationalCloud.Global,
            "0df3f88a-c04e-40ac-8d41-84dbfb9e24d6",
            "*******");

        GraphServiceClient graphClient = (GraphServiceClient) GraphServiceClient.builder()
            .authenticationProvider(authProvider)
            .buildClient();
    }

Tony Ju :

Install via Gradle works fine. Currently(7/19/2019) install via Maven doesn't work.

This is due to com.microsoft.graph.0.1.0-SNAPSHOT has not been updated. You can download the source code of msgraph-sdk-java-auth and exported it as jar file. Use this jar file instead of using com.microsoft.graph.0.1.0-SNAPSHOT. This will work, I have validated this.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=130043&siteId=1