Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/p8 #6648

Open
wants to merge 13 commits into
base: alpha
Choose a base branch
from
Prev Previous commit
Next Next commit
work on p8 with token
  • Loading branch information
Yudhvir authored and Yudhvir committed Apr 23, 2020
commit b3fd1e23b127d68e0b0a24eee63c1e4ccecc93fc
14 changes: 8 additions & 6 deletions src/Adapters/Auth/apple.js
Original file line number Diff line number Diff line change
@@ -11,12 +11,12 @@ const TOKEN_ISSUER = 'https://appleid.apple.com';
const fs = require("fs");
const request = require("request");

function accessToken(configPath, code) {
function accessToken(configPath, privateKeyPath, code) {
const config = JSON.parse(fs.readFileSync(configPath));

return new Promise(
(resolve, reject) => {
generate()
generate(privateKeyPath)
.then(
(token) => {
const payload = {
@@ -117,18 +117,20 @@ const getHeaderFromToken = token => {
const verifyIdToken = async ({
token,
id,
isWebUser
code
}, {
clientId,
cacheMaxEntries,
cacheMaxAge,
p8FilePath,
configFilePath
}) => {
if (isWebUser) {

if (code) {
const response = await accessToken(configFilePath, p8FilePath, code);
token = response.id_token;
id = decodedToken = jwt.decode(token).sub;
}
accessToken

if (!token) {
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,