Giter Club home page Giter Club logo

msgraph-training-java's Introduction

Build Java apps with the Microsoft Graph Java SDK - Completed project

Java CI with Gradle License.

This sample will introduce you to working with the Microsoft Graph SDK to access data in Microsoft 365 from Java applications. This code is the result of completing the Java Microsoft Graph tutorial and the Java Microsoft Graph app-only tutorial.

Running the sample

The code for the delegated user authentication sample is in the user-auth folder. Instructions to configure and run the sample can be found in the README in that folder.

The code for the app-only authentication sample is in the app-auth folder. Instructions to configure and run the sample can be found in the README in that folder.

Code of conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.

msgraph-training-java's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar jasonjoh avatar microsoft-github-policy-service[bot] avatar msftbot[bot] avatar nrjulian avatar sebichondo avatar swagatachaudhuri avatar syx670326 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msgraph-training-java's Issues

Update msal4j version

Update to latest version 1.3.0

Replace in pom.xml:

    <dependency>
      <groupId>com.microsoft.azure</groupId>
      <artifactId>msal4j</artifactId>
      <version>1.3.0</version>
    </dependency>

Authentication do not work

I have followed the tutorials instructions, however I get an authentication error all the time.

AADSTS500201: We are unable to issue tokens from this API version for a Microsoft account. Please contact the application vendor as they need to use version 2.0 of the protocol to support this.

While I try the react version of the tutorial from here it's working perfectly.
Both JavaScript and Java SDK versions are 1.7 (microsoft-graph) and 1.1 (msal).

Select Grant admin consent for..., then select Yes to provide admin consent for the selected permission. is wrong

The readme in app-auth is wrong. The option admin consent for ... does not exist. When running the example I got an error:

[root@mg-wopitest-tux graphapponlytutorial]# sh ./gradlew --console plain run
> Task :app:compileJava UP-TO-DATE
> Task :app:processResources UP-TO-DATE
> Task :app:classes UP-TO-DATE

> Task :app:run
Java App-Only Graph Tutorial

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Please choose one of the following options:
0. Exit
1. Display access token
2. List users
3. Make a Graph call
2
Feb 16, 2023 10:43:04 AM com.microsoft.graph.logger.DefaultLogger logError
Error getting users
SEVERE: CoreHttpProvider[sendRequestInternal] - 408Graph service exception
Feb 16, 2023 10:43:04 AM com.microsoft.graph.logger.DefaultLogger logError
Error code: Authorization_RequestDenied
SEVERE: Throwable detail: com.microsoft.graph.http.GraphServiceException: Error code: Authorization_RequestDenied
Error message: Insufficient privileges to complete the operation.
Error message: Insufficient privileges to complete the operation.

GET https://graph.microsoft.com/v1.0/users?%24select=displayName%2Cid%2Cmail&%24top=25&%24orderby=displayName

SdkVersion : graph-java/v5.45.0

GET https://graph.microsoft.com/v1.0/users?%24select=displayName%2Cid%2Cmail&%24top=25&%24orderby=displayName

SdkVersion : graph-java/v5.45.0
403 : Forbidden

[...]

403 : Forbidden

[...]
[Some information was truncated for brevity, enable debug logging for more details]

Please choose one of the following options:
[Some information was truncated for brevity, enable debug logging for more details]
0. Exit
1. Display access token
2. List users
3. Make a Graph call
0
Goodbye...

BUILD SUCCESSFUL in 19s
3 actionable tasks: 1 executed, 2 up-to-date
[root@mg-wopitest-tux graphapponlytutorial]#

Either update your documentation or fix the problem.

PublicClientApplication class not available

Hi I was working through the tutorial and came across the this error at step "Add Azure AD Authentication". Then when I tried running the demo after cloning this project I got the same error when running the 03-add-msgraph project. I checked the PublicClientApplication class and it is available to use, so now I'm stumped on why the class is not being found. For both projects I made sure to change the oAuth.properties files to use my Azure app config. Thanks
Screen Shot 2020-02-10 at 11 42 48 AM

Validation of email address

Hi Team - Is there any way to validate a email address i.e verify if the such mailbox is existing before sending any mails?

Admin consent for one of the requested scopes could not be added

Where did you get the code?

Describe the bug

Running the register.ps1 script fails when trying to approve admin consent.

To Reproduce

Steps to reproduce the behavior:

register.ps1 -AppName "RSMF Test" -GraphScopes "ChannelMessage.Read.All","Chat.Read.All","Group.Read.All","Team.ReadBasic.All","User.Read.All","Files.Read.All"

Error:

Admin consent for one of the requested scopes could not be added.
Insufficient privileges to complete the operation.

Status: 403 (Forbidden)
ErrorCode: Authorization_RequestDenied
Date: 2023-10-16T14:28:11

Headers:
Cache-Control                 : no-cache
Transfer-Encoding             : chunked
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : e0161e1a-b79b-4e67-afae-c10c720c9875
client-request-id             : 963d9d69-fad3-4e8f-abce-1b24ac849ec4
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"South Central US","Slice":"E","Ring":"5","ScaleUnit":"004","RoleInstance":"SA2PEPF000023FB"}}
x-ms-resource-unit            : 1
Date                          : Mon, 16 Oct 2023 14:28:10 GM


DisplayName Id                                   AppId                                SignInAudience ServicePrincipalType
----------- --                                   -----                                -------------- --------------------
RSMF Test   xxxx-db9e-4869-909d-7b2819b9f00c xxxx-1d39-42dd-b656-ee7ff3be69b1 AzureADMyOrg   Application

Desktop

  • OS: MacOS 13.2.1
  • Browser: chrome (used for OAuth)
  • Version 118.0.5993.70

Dependency versions

  • Az: 10.4.1
  • Microsoft.Graph: 2.6.1

Additional Details

My account used for OAuth can manually grant consent in the Azure console.

AADSTS65002: Consent between first party application '04b07795-8ddb-461a-bbee-02f9e1bf7b46'

Thank you for taking an interest in Microsoft Graph development! Please feel free to ask a question here, but keep in mind the following:

  • This is not an official Microsoft support channel, and our ability to respond to questions here is limited. Questions about Graph, or questions about adding a new feature to the sample, will be answered on a best-effort basis.
  • Questions should be asked on Stack Overflow.
  • Issues with Microsoft Graph itself should be handled through support.

I followed all the instructions per tutorial, bug keep getting Authentication error popup:
AADSTS65002: Consent between first party application '04b07795-8ddb-461a-bbee-02f9e1bf7b46'

Unable to authenticate using AAD

I receive the following after entering the access code at microsoft.com/devicelogin:

AADSTS500201: We are unable to issue tokens from this API version for a Microsoft account. Please contact the application vendor as they need to use version 2.0 of the protocol to support this.

Erro on running App.java

Hi, When I run App.java, I receive this erro:

 Exception in thread "main" java.lang.NoClassDefFoundError: com/nimbusds/oauth2/sdk/auth/ClientAuthentication
	at graph.Authentication.getUserAccessToken(Authentication.java:45)
	at graph.App.main(App.java:39)
Caused by: java.lang.ClassNotFoundException: com.nimbusds.oauth2.sdk.auth.ClientAuthentication
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	... 2 more

I added all the JARs to my project.

-microsoft-graph-1.8.0.jar
-msal4j-1.6.1.jar
-slf4j-nop-1.8.0-beta4.jar

What should be the problem, or missing?Thanks!!

Automate the user Login.

Hi,

It's an amazing program to learn oAuth login with Microsoft. I have a requirement to automatically download inbox for some service email accounts for my organization. How do I automate the system so it won't ask me to login every time with the code?

Thanks,

Mahendra

UpdateAppForAppOnlyAuth.ps1 has an invalid source code

I executed UpdateAppForAppOnlyAuth.ps1 but the following error has appeared.
I think the shell script needs to be fixed.

Get-MgApplication : The specified filter to the reference property query is currently not supported.
発生場所 Z:\msgraph-training-java\demo\UpdateAppForAppOnlyAuth.ps1:31 文字:1

  • $appRegistration = Get-MgApplication -Filter ("appId eq '" + $AppId + ...
  •   + CategoryInfo          : InvalidOperation: ({ ConsistencyLe...ndProperty =  }:<>f__AnonymousType24`9) [Get-MgAppl
     ication_List1]、RestException`1
      + FullyQualifiedErrorId : Request_UnsupportedQuery,Microsoft.Graph.PowerShell.Cmdlets.GetMgApplication_List1
    

How to adapt this to server-side or daemon application?

This uses the PublicClientApplication class

Following questions need to be answered:

  1. how does the app registration process change? Can we use a client secret or do we need to use certificates? Where is this information found?

  2. Do we need to set the Redirect URI with daemon application?

  3. What is the correct syntax for providing the scope string? I've seen everything online from "Mail.ReadWrite" to"https://graph.microsoft.com/.default"

  4. How does this change if we use the ConfidentialClientApplication class?

not work

hi
many thanks for your tutorial
but despite I follow the tutorial but at the end I encounter to this error:

Task :compileJava
C:\firefox_Driver\msgraph-training-java-master\demo\graphtutorial\src\main\java\graphtutorial\Authentication.java:38: error: ca
nnot find symbol
Set scopeSet = Set.of(scopes);
^
symbol: method of(String[])
location: interface Set
1 error

Task :compileJava FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':compileJava'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan
    to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 13s
1 actionable task: 1 executed

I would be pleased if you can help me!

I'm new to java and ms graph and I just need to upload an excel file to one drive programmatically using java.

many thanks in advance!

error on using api

Hi
could you please let me know what is this error?
Caused by: com.microsoft.graph.core.ClientException: Error during http request

I'm using my personal microsoft account for uploading excel file on onedrive...! is this caused the problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.