laardee / serverless-authentication-boilerplate

Generic authentication boilerplate for Serverless framework
http://laardee.github.io/serverless-authentication-gh-pages
MIT License
568 stars 71 forks source link

how do you get the access_token? #14

Closed mankins closed 2 years ago

mankins commented 8 years ago

I'm writing a custom provider, and looking at how to get access to the access_token in the callback respones. It looks buried in serverless-authentication which seems to return a profile, but no access_token. But maybe I'm missing something?

laardee commented 8 years ago

Yes, the authentication flow is buried to the provider class https://github.com/laardee/serverless-authentication/blob/master/src/provider.js. How are you planning to use the access_token later on?

mankins commented 8 years ago

I was planning on making subsequent api calls once the initial flow has been started. I'd use the auth'd api from within the lambda function/app later on. Which would require access to the token.

laardee commented 8 years ago

I don't see a reason why it couldn't be returned along with the profile. I added it to provider class and it will be available in _raw (profile._raw.access_token). I'll do some other improvements before I publish this to npm, but i'll try to do that as soon as possible.

mankins commented 8 years ago

thanks!

laardee commented 8 years ago

In serverless-authentication v.0.4.4 (in npm) access_token is mapped as profile.at_hash as defined in OpenId standard (instead of profile._raw.access_token). I decide to use that because I've started to implement some Cognito features (#8 and #9) which uses OpenId fields.

nishtha3006 commented 8 years ago

Heyy i tried to install the project but it is giving me error.I tried to figure it out but no clue. Can you help me with this??

npm ERR! Linux 3.19.0-58-generic npm ERR! argv "/home/nishtha/.nvm/versions/node/v4.3.2/bin/node" "/home/nishtha/.nvm/versions/node/v4.3.2/bin/npm" "install" npm ERR! node v4.3.2 npm ERR! npm v2.14.12 npm ERR! path /home/nishtha/.npm/lodash/4.13.0 npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall mkdir

npm ERR! Error: EACCES: permission denied, mkdir '/home/nishtha/.npm/lodash/4.13.0' npm ERR! at Error (native) npm ERR! { [Error: EACCES: permission denied, mkdir '/home/nishtha/.npm/lodash/4.13.0'] npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'mkdir', npm ERR! path: '/home/nishtha/.npm/lodash/4.13.0', npm ERR! parent: 'async' } npm ERR! npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request: npm ERR! /tmp/__sls_project_install_serverless-authentication-boilerplate_1463997196535/node_modules/serverless-authentication-boilerplate/authentication/npm-debug.log npm ERR! Linux 3.19.0-58-generic npm ERR! argv "/home/nishtha/.nvm/versions/node/v4.3.2/bin/node" "/home/nishtha/.nvm/versions/node/v4.3.2/bin/npm" "install" "serverless-authentication-boilerplate" npm ERR! node v4.3.2 npm ERR! npm v2.14.12 npm ERR! code ELIFECYCLE

npm ERR! serverless-authentication-boilerplate@0.6.3 install: cd authentication && npm install && cd ../authorization && npm install npm ERR! Exit status 243 npm ERR! npm ERR! Failed at the serverless-authentication-boilerplate@0.6.3 install script 'cd authentication && npm install && cd ../authorization && npm install'. npm ERR! This is most likely a problem with the serverless-authentication-boilerplate package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! cd authentication && npm install && cd ../authorization && npm install npm ERR! You can get their info via: npm ERR! npm owner ls serverless-authentication-boilerplate npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! /tmp/__sls_project_install_serverless-authentication-boilerplate_1463997196535/npm-debug.log ] killed: false, code: 1, signal: null, cmd: '/bin/sh -c npm install serverless-authentication-boilerplate' }, isOperational: true, killed: false, code: 1, signal: null, cmd: '/bin/sh -c npm install serverless-authentication-boilerplate' }

laardee commented 8 years ago

@nishtha3006 you could create a new issue about this, but I guess the problem could be the npm install script. You could remove

"install": "cd authentication && npm install && cd ../authorization && npm install",

from package json. Then run npm install (maybe with sudo in your case?) in project root, authentication and authorization folders.