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() {
|
export async function GET() {
|
||||||
const settings = getSettings();
|
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') {
|
if (!appId || appId === 'your_meta_app_id') {
|
||||||
return NextResponse.json(
|
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 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const scopes = [
|
const scopes = [
|
||||||
'ads_management',
|
'ads_management',
|
||||||
'ads_read',
|
'ads_read',
|
||||||
'business_management',
|
'business_management',
|
||||||
'pages_show_list',
|
'pages_show_list',
|
||||||
'pages_read_engagement',
|
'pages_read_engagement',
|
||||||
].join(',');
|
].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('client_id', appId);
|
||||||
authUrl.searchParams.set('redirect_uri', redirectUri);
|
authUrl.searchParams.set('redirect_uri', redirectUri);
|
||||||
authUrl.searchParams.set('scope', scopes);
|
authUrl.searchParams.set('scope', scopes);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue