config tweaks
This commit is contained in:
@ -4,14 +4,17 @@ import axios from 'axios';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const dotenv = require("dotenv");
|
||||
|
||||
export default async function handler(req, res) {
|
||||
if (req.method === 'GET') {
|
||||
// Generate the client secret
|
||||
const clientSecret = generateClientSecret();
|
||||
const redirectUri = `${req.headers.origin}/api/auth/apple/callback`;
|
||||
// const redirectUri = `${req.headers.origin}/api/auth/apple/callback`;
|
||||
const redirectUri = `https://sofia.mwitnessing.com/api/auth/callback/apple`;
|
||||
|
||||
// Redirect to Apple's authorization page
|
||||
res.redirect(`https://appleid.apple.com/auth/authorize?response_type=code&client_id=${process.env.APPLE_CLIENT_ID}&redirect_uri=${encodeURIComponent(redirectUri)}&scope=name+email&response_mode=form_post&state=STATE&client_secret=${encodeURIComponent(clientSecret)}`);
|
||||
res.redirect(`https://appleid.apple.com/auth/authorize?response_type=code&client_id=${process.env.APPLE_APP_ID}&redirect_uri=${encodeURIComponent(redirectUri)}&scope=name+email&response_mode=form_post&state=STATE&client_secret=${encodeURIComponent(clientSecret)}`);
|
||||
} else {
|
||||
res.status(405).json({ error: 'Method not allowed' });
|
||||
}
|
||||
@ -21,7 +24,7 @@ function generateClientSecret() {
|
||||
const appleKey = fs.readFileSync(path.resolve('./_deploy/appleKey.p8'), 'utf8');
|
||||
const teamID = process.env.APPLE_TEAM_ID || "XC57P9SXDK";
|
||||
const keyID = process.env.APPLE_KEY_ID || "TB3V355G5Y";
|
||||
const appleAppID = process.env.APPLE_APP_ID || "com.mwitnessing.mwitnessing";
|
||||
const appleAppID = process.env.APPLE_APP_ID;
|
||||
|
||||
// Token expiration
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
|
Reference in New Issue
Block a user