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 { useTranslation, Trans } from 'next-i18next' import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import siteConfig from '../../config/site.config' 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 { t } = useTranslation() const oAuthUrl = generateAuthorisationUrl() return (
{t('OAuth Step 2 - {{title}}', { title: siteConfig.title })}
fabulous come back later

{t('Welcome to your new onedrive-vercel-index 🎉')}

{t('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)) }} />

{t('The authorisation code extracted is:')}

{authCode || {t('Waiting for code...')}}

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

) } export async function getServerSideProps({ locale }) { return { props: { ...(await serverSideTranslations(locale, ['common'])), }, } }