1

I want to Implement Microsoft Graph API for sending an email.

For that, I have referred the code from https://github.com/microsoftgraph/console-java-connect-sample.

But, The code present here is in Gradle format. I need it in Maven format.

What I Want to do is :

  1. Get The access token from GraphAPI
  2. Using This Access token Call the Send Mail API of GraphAPI

I have perfrom above two functionality using postman.

same I want to implement using Java & Maven

Please let me know if any sample available for this functionality using Maven

2
  • What functionality exactly? Please add the description of what you have and what you try to achieve to the question. Commented Jul 30, 2019 at 13:40
  • @JFMeier I have Updated the question as per knowledge Commented Jul 30, 2019 at 14:41

1 Answer 1

2

Maven and Gradle are just build tools. You can use that sample, just need to create a pom.xml file with dependencies used in build.gradle file. I have done that for you.

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>test2</groupId>
    <artifactId>test2</artifactId>
    <version>1.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>com.nimbusds</groupId>
        <artifactId>oauth2-oidc-sdk</artifactId>
        <version>4.5</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20090211</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.github.scribejava</groupId>
        <artifactId>scribejava-apis</artifactId>
        <version>6.2.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
    </dependency>
    <dependency>
        <groupId>com.gilecode.yagson</groupId>
        <artifactId>j9-reflection-utils</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>com.microsoft.graph</groupId>
        <artifactId>microsoft-graph</artifactId>
        <version>1.5.0</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
    <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
    </build>
</project>

Download that sample and delete all the files except src folder, put the pom.xml together with src folder. A maven project has done.

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot. It worked.BTW do you have any idea how can we get authorization code
@E_FreeLancer added the answer there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.