# Can not verify JWT token of Azure AD with openid scope in java

**URL:** <https://community.auth0.com/t/can-not-verify-jwt-token-of-azure-ad-with-openid-scope-in-java/109590>\
**Category:** Get Help\
**Tags:** directory-authorization, third-party-client-applications\
**Created:** [June 20, 2023, 12:16pm UTC](https://community.auth0.com/t/can-not-verify-jwt-token-of-azure-ad-with-openid-scope-in-java/109590 "2023-06-20T12:16:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadinhilperters](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kadinhilperters/32/48183_2.png) [@kadinhilperters](https://community.auth0.com/u/kadinhilperters)\
**Post date:** [June 20, 2023, 12:16pm UTC](https://community.auth0.com/t/can-not-verify-jwt-token-of-azure-ad-with-openid-scope-in-java/109590/1 "2023-06-20T12:16:03Z")

</div>

I am developing a Backend code for a [BallSportsGear](https://www.ballsportsgear.com/) to log in to our application in Login with Azure Ad User. I have to be able to make a JWT Verify. I read too many posts. I’m trying to use the AUTH0 library. I have tried a lot, but still "com.auth Where do I make mistakes?

```auto
import NextAuth from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";

const handler = NextAuth({
  providers: [
    CredentialsProvider({
      name: "Credentials",
      credentials: {
        username: { label: "Username", type: "text" },
        password: { label: "Password", type: "password" },
      },
      async authorize(credentials, req) {
        const { username, password } = credentials as { username: string; password: string };
        const res = await fetch("http://localhost:3000/api/auth/login", {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify({ username, password }),
        });
        const user = await res.json();
        if (res.ok) {
          return user;
        } else {
          return null;
        }
      },
    }),
  ],
  session: {
    strategy: "jwt"
  },
});

export { handler as GET, handler as POST };

```

layout.tsx

```auto
'use client'

import './globals.css'
import { SessionProvider } from "next-auth/react"

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en">
      <body>
        <SessionProvider>
          {children}
        </SessionProvider>
      </body>
    </html>
  )
}

```

---

<div class="post-metadata">

**Author:** ![kimia.salamo9881](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kimia.salamo9881/32/36235_2.png) [@kimia.salamo9881](https://community.auth0.com/u/kimia.salamo9881)\
**Post date:** [June 21, 2023, 4:02am UTC](https://community.auth0.com/t/can-not-verify-jwt-token-of-azure-ad-with-openid-scope-in-java/109590/2 "2023-06-21T04:02:10Z")

</div>

First of all you have to Import Statement In the first code snippet, you import `CredentialsProvider` from `next-auth/providers/credentials`. However, for Azure AD authentication, you should use the `AzureAdProvider` instead. Make sure you have installed the `next-auth` and `@next-auth/azure-ad` packages. Then rovider Configuration: Update your NextAuth configuration to include the AzureAdProvider with the required configuration options, such as clientId, clientSecret, tenantId, etc. These values can be obtained from your Azure AD application registration.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [July 5, 2023, 4:03am UTC](https://community.auth0.com/t/can-not-verify-jwt-token-of-azure-ad-with-openid-scope-in-java/109590/3 "2023-07-05T04:03:01Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
