max-mapper / max-mapper/github-oauth

add other providers (like facebook)

Open
#3 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
71
Forks
20
PR merge metrics
No merged PRs in 30d

Description

e.g.


t
    .route('/auth/facebook/callback/:id', function (req, resp) {
        if (req.qs.code) {
          setFacebookCode(req.qs.code, function (e) {
            if (e) return resp.error(e)
            token.redirect(resp)
          })
        } else if (req.qs.access_token) {
          // Something bad happened and the redirect url was followed.
          // Hopefully it's just our own client and we can return the expected body
          resp.end(qs.stringify(req.qs))
        } else {
          logger.error('WHY!')
          // TODO find error
        }
    })

function setFacebookCode(code, cb) {
    var self = this
      , q =
        { code: code
        , client_id: this.client.facebook_client_id
        , client_secret: this.client.facebook_client_secret
        // eventually needs to use subdomain
        , redirect_uri: baseURL + 'auth/facebook/callback/'+self._id 
        }
      ;
    // It's important to know that this doesn't forward to the redirect uri
    request.get('https://graph.facebook.com/oauth/access_token?'+qs.stringify(q), function (e, r, body) {
      if (e) return cb(e)
      if (r.statusCode !== 200) return cb(new ServiceError('Error: '+body))
      self.setFacebookToken(qs.parse(body), cb)
    })
  }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the /auth/facebook/callback/:id route and setFacebookCode example, then inspect the existing GitHub OAuth entry point. Done means an agreed additional provider can complete its callback and token exchange, including defined error behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
authentication
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.