Last active
April 5, 2019 19:38
-
-
Save mauricionr/ce4c4af9eb845735a825 to your computer and use it in GitHub Desktop.
Revisions
-
mauricionr revised this gist
Dec 12, 2015 . 1 changed file with 0 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,6 @@ var request = require('request'); var jwt = require('jsonwebtoken') function getAccessToken(req) { //https://gist.github.com/demelziraptor/9039435 Python //http://www.getcodesamples.com/src/A39B1460/F692912D PHP req.session.sp_info = req.query; -
mauricionr revised this gist
Sep 17, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,6 @@ var request = require('request'); var jwt = require('jsonwebtoken') function getAccessToken(req) { /** * Code to get access token for sharepoint provider hosted apps in context token flow * Thanks both code above and TokenHelper.cs */ -
mauricionr revised this gist
Sep 17, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ var jwt = require('jsonwebtoken') function getAccessToken(req) { /** * Author:Mauricio Nunes dos reis * Code to get access token for sharepoint provider hosted apps in context token flow * Thanks both code above and TokenHelper.cs */ //https://gist.github.com/demelziraptor/9039435 Python -
mauricionr created this gist
Sep 17, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ var request = require('request'); var jwt = require('jsonwebtoken') function getAccessToken(req) { /** * Author:Mauricio Nunes dos reis * Code to get access token for sharepoint provider hosted apps * Thanks both code above and TokenHelper.cs */ //https://gist.github.com/demelziraptor/9039435 Python //http://www.getcodesamples.com/src/A39B1460/F692912D PHP req.session.sp_info = req.query; req.session.sp_oauth = req.body; var client_ID = "{{clientID}}" var appSecret = '{{appSecret}}'; var decoded = jwt.decode(req.session.sp_oauth.SPAppToken, appSecret) decoded.appctx = JSON.parse(decoded.appctx); var appctx = decoded.appctx; var options = { headers: { "Content-Type": "application/x-www-form-urlencoded" }, form: { "grant_type": "refresh_token", "client_id": client_ID + '@' + decoded['appctxsender'].split('@')[1], "client_secret": appSecret, "refresh_token": decoded.refreshtoken, "resource": decoded['appctxsender'].split('@')[0] + '/' + "<domain>.sharepoint.com" + '@' + decoded['appctxsender'].split('@')[1] } }; console.log('\noptions\n', JSON.stringify(options)); var callback = function (req, res, body) { console.log(JSON.stringify(body)); } request.post(appctx.SecurityTokenServiceUri, options, callback) }