What's wrong with this auth code? [closed]

+2 votes
103 views
https://github.com/GuilloryDupre/DNAngulator/blob/main/auth.js

The call to authenticate() is commented out in the live app, because I couldn't get it to work as expected. The login form submission, authcode submission, and checkLogin verification all seem to work correctly (returning "Success" and "Ok" for example)...

But when the app actually does an API call, like getAncestors, it returns the same JSON as if still not logged in. Specifically, it does not return first names of living profiles.

Although, it does return first names of living profiles if the user is logged in to WikiTree Apps via another way (homepage or another app like DNAconf).

So for now, I just have a link to WikiTree Apps homepage as a way to login. But it opens a new tab that doesn't redirect back to the app, so it's not a nice UX.

I hope someone can look at the code and spot what's wrong.

https://apps.wikitree.com/apps/guillory1078/dnangulator/

If this gets solved, I hope we can rewrite the API auth docs to use ES6 (e.g. fetch) instead of the cumbersome XMLHttpRequest and JQuery.
WikiTree profile: Anonymous Dupre
closed with the note: answered
in WikiTree Tech by Anonymous Dupre G2G6 (6.8k points)
closed by Anonymous Dupre
Tip: you can close the question once it is answered.

1 Answer

+7 votes
 
Best answer
I forgot to add { credentials: 'include' } with the fetch() requests for authentication, but did not forget this for the API calls, which is why the API calls were recognizing being logged in but why my app couldn't support logging in itself.
by Anonymous Dupre G2G6 (6.8k points)

Related questions

+7 votes
1 answer
341 views asked Jan 19, 2022 in WikiTree Tech by Ken McEvoy G2G6 Mach 1 (12.1k points)
+10 votes
2 answers
+6 votes
1 answer
114 views asked Aug 17, 2016 in WikiTree Tech by Debra Payne G2G Crew (310 points)
+2 votes
0 answers
+101 votes
110 answers

WikiTree  ~  About  ~  Help Help  ~  Search Person Search  ~  Surname:

disclaimer - terms - copyright

...