javascript - Get Github repo data after authenticating with OAuth and Auth0 -


what want do, private repo datas (issues amount) small application.

since don't want expose personal github access_token in request searched solution think oauth.

so setted oauth following these , these steps.

and setted permissions in auth0 in social github settings repo (grants read/write access repos).

until works fine, i'm able authenticate github account.

but don't know token have use request github api.

here relevant code have far:

const  handleauthentication = () => {   webauth.parsehash((err, authresult) => {     if (authresult && authresult.accesstoken && authresult.idtoken) {       window.location.hash = '';       setsession(authresult);        //here call relevant function       getissues('my-element', /*here should pass correct token*/); //tryed tokens found in authresult      } else if (err) {       alert(         `error: ${err.error} . check console further details.`       );     }   }); }  const getissues = (element, token) => {   const request = new xmlhttprequest();   request.open('get', `https://api.github.com/repos/my_organization/element-${element}/issues?access_token=${token}`, true);    request.onload = () => {     if (request.status >= 200 && request.status < 400) {       const data = json.parse(request.responsetext);       //use data     } else {       console.log('error');     }   };    request.onerror = function(e) {     console.log('connection error: ', e)   };    request.send(); } 

but results 401 (unauthorized) response.

i didn't use xmlhttprequests lot , i'm sure, i'm missing fundamental here.

and i'm not sure if oauth correct way achieve want.

any appreciated.

edit:

meanwhile did more research , found out (here), there steps missing correct user access_token connecting github api.

i'll try complete these steps , post answer if works.

would still appreciate clear answer if knows how exactly.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

Why does math.random(999999999999) returns 1 in Lua? -