Skip to content

Authorize GitHub OAuth Apps from the client-side serverless-ly

License

Notifications You must be signed in to change notification settings

codegram/serverless-github-login

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless GitHub login

A simple Lambda function deployed to AWS with Serverless Framework that allows implementing the GitHub OAuth Web Application Flow.

Usage

  • Update the org field on the serverless.yml
  • Create the variables in AWS Systems Manager Parameter Store:
    • /github-login/dev/clientId OAuth client id for development app, type String
    • /github-login/prod/clientId OAuth client id for production app, type String
    • /github-login/dev/clientSecret OAuth client secret for development app, type SecureString
    • /github-login/prod/clientSecret OAuth client secret for production app, type SecureString
  • Deploy:
    • serverless deploy --stage prod
    • serverless deploy --stage dev

From your client side you can now exchange the code for the token. For more information check GitHub's documentation.

var code = window.location.href.match(/\?code=(.*)/)[1];

fetch(`${YOUR_AWS_URL}/login`, {
    method: "POST",
    body: JSON.stringify({
      code
    })
  })

About

Authorize GitHub OAuth Apps from the client-side serverless-ly

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published