问题
from https://github.com/microsoftgraph/nodejs-connect-rest-sample
i can signin through the first step and i see my microsoft account name already but when i click to send a test email it's not working it respond me this
After I clone this example from github i just modify a bit of code (Insert My APIKEY and clientID at /utils/config.js )
module.exports = {
creds: {
redirectUrl: 'http://localhost:3000/token',
clientID: 'd5cec81e-13b3-XXXX-b90f-de0b123feaa4',
clientSecret: '9G8ay7BhvXXXXXX35JXONhSc',
identityMetadata: 'https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration',
allowHttpForRedirectUrl: true, // For development only
responseType: 'code',
validateIssuer: false, // For development only
responseMode: 'query',
scope: ['User.Read', 'Mail.Send', 'Files.ReadWrite']
}
};
and I compiled and run it . that's all
here is my log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@3.10.10
3 info using node@v6.10.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle nodejs-microsoft-graph-connect@2.0.0prestart: nodejs-microsoft-graph-connect@2.0.0
6 silly lifecycle nodejs-microsoft-graph-connect@2.0.0prestart: no script for prestart, continuing
7 info lifecycle nodejs-microsoft-graph-connect@2.0.0start: nodejs-microsoft-graph-connect@2.0.0
8 verbose lifecycle nodejs-microsoft-graph-connect@2.0.0start: unsafe-perm in lifecycle true
9 verbose lifecycle nodejs-microsoft-graph-connect@2.0.0start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/st4rboy/Desktop/Intern/nodejs-connect-rest-sample-master/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
10 verbose lifecycle nodejs-microsoft-graph-connect@2.0.0start: CWD: /Users/st4rboy/Desktop/Intern/nodejs-connect-rest-sample-master
11 silly lifecycle nodejs-microsoft-graph-connect@2.0.0start: Args: [ '-c', 'mocha ./tests/confTest.js && node ./bin/www' ]
12 silly lifecycle nodejs-microsoft-graph-connect@2.0.0start: Returned: code: 1 signal: null
13 info lifecycle nodejs-microsoft-graph-connect@2.0.0~start: Failed to exec start script
14 verbose stack Error: nodejs-microsoft-graph-connect@2.0.0 start: mocha ./tests/confTest.js && node ./bin/www
14 verbose stack Exit status 1
14 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:886:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid nodejs-microsoft-graph-connect@2.0.0
16 verbose cwd /Users/st4rboy/Desktop/Intern/nodejs-connect-rest-sample-master
17 error Darwin 16.6.0
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
19 error node v6.10.3
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error nodejs-microsoft-graph-connect@2.0.0 start: mocha ./tests/confTest.js && node ./bin/www
22 error Exit status 1
23 error Failed at the nodejs-microsoft-graph-connect@2.0.0 start script 'mocha ./tests/confTest.js && node ./bin/www'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the nodejs-microsoft-graph-connect package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error mocha ./tests/confTest.js && node ./bin/www
23 error You can get information on how to open an issue for this project with:
23 error npm bugs nodejs-microsoft-graph-connect
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls nodejs-microsoft-graph-connect
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
回答1:
I just downloaded and ran the sample and ran into a few issues as well. I can't tell the specific error that you're hitting based on your log, but here's some tips for getting the sample to work. Some of these are bugs in the sample and I've notified our engineers that maintain the samples.
- There's a bug in the renderError() method that causes the error page not to render and that might be why your browser is showing an empty page. I recommend setting breakpoints around the
sendMailmethod to see the actual error until the error handling is fixed. In Visual Studio Code (the lightweight IDE, not Visual Studio), it's as easy as clicking to the left of the line numbers.
- Clicking the send email button actually kicks off a process to fetch the user's profile photo, uploads it to OneDrive and gets a sharing link to insert into the email message body. If any of these operations fail, the email won't be sent. I recommend setting breakpoints around
prepForEmailMessage()in index.js to see if any of these aren't working. For example, if your user doesn't have a profile picture, that GET request will result in a 404 which causes the mail not to be sent.
来源:https://stackoverflow.com/questions/44430650/sendmail-function-seem-not-working-with-microsoft-graph