import Head from 'next/head' import Image from 'next/image' import { useRouter } from 'next/router' import { useState } from 'react' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import siteConfig from '../../config/site.json' import Navbar from '../../components/Navbar' import Footer from '../../components/Footer' import { LoadingIcon } from '../../components/Loading' import { extractAuthCodeFromRedirected, generateAuthorisationUrl } from '../../utils/oAuthHandler' export default function OAuthStep2() { const router = useRouter() const [oAuthRedirectedUrl, setOAuthRedirectedUrl] = useState('') const [authCode, setAuthCode] = useState('') const [buttonLoading, setButtonLoading] = useState(false) const oAuthUrl = generateAuthorisationUrl() return (
{`OAuth Step 2 - ${siteConfig.title}`}
fabulous come back later

Welcome to your new onedrive-vercel-index 🎉

Step 2/3: Get authorisation code

If you are not the owner of this website, stop now, as continuing with this process may expose your personal files in OneDrive.

{ window.open(oAuthUrl) }} >
                {oAuthUrl}
              

The OAuth link for getting the authorisation code has been created. Click on the link above to get the{' '} authorisation code. Your browser will open a new tab to Microsoft's account login page. After logging in and authenticating with your Microsoft account, you will be redirected to a blank page on localhost. Paste{' '} the entire redirected URL down below.

step 2 screenshot
{ setOAuthRedirectedUrl(e.target.value) setAuthCode(extractAuthCodeFromRedirected(e.target.value)) }} />

The authorisation code extracted is:

{authCode || Waiting for code...}

{authCode ? '✅ You can now proceed onto the next step: requesting your access token and refresh token.' : '❌ No valid code extracted.'}

) }