Atualizar src/app/api/auth/meta/route.ts
This commit is contained in:
parent
61b5303ee5
commit
348723f39f
1 changed files with 24 additions and 12 deletions
|
|
@ -7,25 +7,37 @@ import { getSettings } from '@/lib/settings';
|
|||
|
||||
export async function GET() {
|
||||
const settings = getSettings();
|
||||
const appId = settings.metaAppId || process.env.META_APP_ID;
|
||||
const redirectUri = process.env.META_REDIRECT_URI || 'http://localhost:3000/api/auth/callback';
|
||||
|
||||
const appId =
|
||||
settings.metaAppId ||
|
||||
process.env.META_APP_ID;
|
||||
|
||||
const redirectUri =
|
||||
process.env.META_REDIRECT_URI ||
|
||||
'https://admanager.seureview.com.br/api/auth/callback';
|
||||
|
||||
if (!appId || appId === 'your_meta_app_id') {
|
||||
return NextResponse.json(
|
||||
{ error: 'App ID não configurado. Acesse a tela de login e clique em Configurar.' },
|
||||
{
|
||||
error:
|
||||
'App ID não configurado. Acesse a tela de login e clique em Configurar.',
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
const scopes = [
|
||||
'ads_management',
|
||||
'ads_read',
|
||||
'business_management',
|
||||
'pages_show_list',
|
||||
'pages_read_engagement',
|
||||
].join(',');
|
||||
const scopes = [
|
||||
'ads_management',
|
||||
'ads_read',
|
||||
'business_management',
|
||||
'pages_show_list',
|
||||
'pages_read_engagement',
|
||||
].join(',');
|
||||
|
||||
const authUrl = new URL(
|
||||
'https://www.facebook.com/v20.0/dialog/oauth'
|
||||
);
|
||||
|
||||
const authUrl = new URL('https://www.facebook.com/v20.0/dialog/oauth');
|
||||
authUrl.searchParams.set('client_id', appId);
|
||||
authUrl.searchParams.set('redirect_uri', redirectUri);
|
||||
authUrl.searchParams.set('scope', scopes);
|
||||
|
|
@ -33,4 +45,4 @@ export async function GET() {
|
|||
authUrl.searchParams.set('state', crypto.randomUUID());
|
||||
|
||||
return NextResponse.redirect(authUrl.toString());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue