# How to solve problem with oAuth Zoom in Nextjs?

**URL:** <https://devforum.zoom.us/t/how-to-solve-problem-with-oauth-zoom-in-nextjs/63143>\
**Category:** API and Webhooks\
**Created:** [January 25, 2022, 7:35am UTC](https://devforum.zoom.us/t/how-to-solve-problem-with-oauth-zoom-in-nextjs/63143 "2022-01-25T07:35:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kanwal\_Aftab](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/kanwal_aftab/32/34419_2.png) [@Kanwal\_Aftab](https://devforum.zoom.us/u/Kanwal_Aftab)\
**Post date:** [January 25, 2022, 7:35am UTC](https://devforum.zoom.us/t/how-to-solve-problem-with-oauth-zoom-in-nextjs/63143/1 "2022-01-25T07:35:05Z")

</div>

I am trying to authenicat the user inorder to get data to use to create or update meetings later. but it full of errors. Here I am sending Post request in order to get the AccessToken and then get the userData as Props.

```auto
export async function getServerSideProps(res){

const oauth = async() => {
     const zoomUserData = [];
       const b = Buffer.from(process.env.ZOOM_API_KEY + ":" + process.env.ZOOM_API_SECRET);

 const zoomRes = await fetch(`https://zoom.us/oauth/token?grant_type=authorization_code&code=${req.body.code}&redirect_uri=${process.env.ZOOM_REDIRECT_URL}`, {
   method: "POST",
   headers: {
     Authorization: `Basic ${b.toString("base64")}`,
   },
 });
 const zoomData = await zoomRes.json();
 const zoomUserRes = await fetch("https://api.zoom.us/v2/users/me", {
   method: "GET",
   headers: {
     Authorization: `Bearer ${zoomData.access_token}`,
   },
 });
 const zoomUserData = await zoomUserRes.json();

 /* 
   Encrypt and store below details to your database:
     zoomUserData.email
     zoomUserData.account_id
     zoomData.access_token
     zoomData.refresh_token
     zoomData.expires_in // convert it to time by adding these seconds to current time
 */

}

return{
     props:{zoomUserData}
   }
 }

```

and then [i](https://tinyurl.com/5n6njbnd/) am passing the props to a page component like that :

```auto
export default function Meeting({zoomUserData}) { 
  const router = useRouter();  
      useEffect(() => {    
         if (router.query.code) { 
             fetch('/connectZoom',
              { method: 'POST',
         headers: {
           'ContType': 'application/json',
         },
         body: JSON.stringify({ code: router.query.code }),
       }).then(() => {
         console.log("success")
       }).catch(() => {
         console.log("No!")    
   });
     }
   }, [router.query.code]);
   console.log(zoomUserData)

   return (

     <a href={`https://zoom.us/oauth/authorize?response_type=code&client_id=${process.env.ZOOM_API_KEY}&redirect_uri=${process.env.ZOOM_REDIRECT_URL}`}>
       Connect Zoom
 </a>

   )
 }

```

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [February 1, 2022, 12:59am UTC](https://devforum.zoom.us/t/how-to-solve-problem-with-oauth-zoom-in-nextjs/63143/2 "2022-02-01T00:59:38Z")

</div>

Hi @Kanwal_Aftab

Thank you for reaching out to the Zoom Developer Forum, I am happy to help here!  
Have you tried making this request via Postman and confirm that you are getting the response you are looking for?

---

<div class="post-metadata">

**Author:** ![tamnasidhart](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tamnasidhart/32/18791_2.png) [@tamnasidhart](https://devforum.zoom.us/u/tamnasidhart)\
**Post date:** [February 3, 2022, 9:28am UTC](https://devforum.zoom.us/t/how-to-solve-problem-with-oauth-zoom-in-nextjs/63143/3 "2022-02-03T09:28:58Z")

</div>

You forget to mention what Error are you gett[i](https://www.olansith.com)ng? So it would be helpful to explain the mistake.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [March 5, 2022, 7:29pm UTC](https://devforum.zoom.us/t/how-to-solve-problem-with-oauth-zoom-in-nextjs/63143/4 "2022-03-05T19:29:49Z")

</div>

Closed on March 5, 2022, 7:29pm UTC

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