{"id":20424935,"url":"https://github.com/genfirst/passport-bitbucket-token","last_synced_at":"2025-06-17T21:41:43.365Z","repository":{"id":57319959,"uuid":"87569639","full_name":"GenFirst/passport-bitbucket-token","owner":"GenFirst","description":"Passport strategy for authenticating with Bitbucket access tokens using the OAuth 2.0 API.","archived":false,"fork":false,"pushed_at":"2017-06-30T23:51:12.000Z","size":32,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-09T12:35:45.009Z","etag":null,"topics":["bitbucket","bitbucket-cloud","bitbucket-oauth2-provider","passport-bitbucket","passport-bitbucket-token","passport-strategy","passportjs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GenFirst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-07T17:17:16.000Z","updated_at":"2017-08-08T04:02:09.000Z","dependencies_parsed_at":"2022-08-25T21:00:54.439Z","dependency_job_id":null,"html_url":"https://github.com/GenFirst/passport-bitbucket-token","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/GenFirst/passport-bitbucket-token","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenFirst%2Fpassport-bitbucket-token","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenFirst%2Fpassport-bitbucket-token/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenFirst%2Fpassport-bitbucket-token/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenFirst%2Fpassport-bitbucket-token/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GenFirst","download_url":"https://codeload.github.com/GenFirst/passport-bitbucket-token/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenFirst%2Fpassport-bitbucket-token/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260445324,"owners_count":23010361,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitbucket","bitbucket-cloud","bitbucket-oauth2-provider","passport-bitbucket","passport-bitbucket-token","passport-strategy","passportjs"],"created_at":"2024-11-15T07:11:34.005Z","updated_at":"2025-06-17T21:41:38.347Z","avatar_url":"https://github.com/GenFirst.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# passport-bitbucket-token\n\n[![NPM](https://nodei.co/npm/passport-bitbucket-token.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/passport-bitbucket-token/)\n\n[![Build Status](https://travis-ci.org/GenFirst/passport-bitbucket-token.svg?branch=master)](https://travis-ci.org/GenFirst/passport-bitbucket-token)\n[![Coverage Status](https://coveralls.io/repos/github/GenFirst/passport-bitbucket-token/badge.svg?branch=master)](https://coveralls.io/github/GenFirst/passport-bitbucket-token?branch=master)\n[![Dependency Status](https://gemnasium.com/badges/github.com/GenFirst/passport-bitbucket-token.svg)](https://gemnasium.com/github.com/GenFirst/passport-bitbucket-token)\n[![Code Climate](https://codeclimate.com/github/GenFirst/passport-bitbucket-token/badges/gpa.svg)](https://codeclimate.com/github/GenFirst/passport-bitbucket-token)\n[![npm version](https://badge.fury.io/js/passport-bitbucket-token.svg)](https://badge.fury.io/js/passport-bitbucket-token)\n![License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n[Passport](http://passportjs.org/) strategy for authenticating with [Bitbucket](https://bitbucket.org/) access tokens using the OAuth 2.0 API.\n\nLibrary is inspired by [passport-facebook-token](https://github.com/drudge/passport-facebook-token).\n\n## Installation\n\n`npm install passport-bitbucket-token`\n\n## Usage\n\n### Configure Strategy\n\nThe Bitbucket authentication strategy authenticate users using Bitbucket account and OAuthe 2 tokens. The strategy requires two parameters: `options` and `verify` callback. \n`options` are used to configure strategy. `verify` callback is function that accepts 4 arguments: `accessToken`, `refreshToken`, `profile`, `done`. `profile` is parsed Bitbucket profile. `done` is method which is called with user when `verify` method is finished. \n\n```js\nvar BitbucketTokenStrategy = require('passport-bitbucket-token');\n\npassport.use(new BitbucketTokenStrategy({\n      clientID: 'app-id',\n      clientSecret: 'client-secret'\n    },\n    function (accessToken, refreshToken, profile, done) {\n      User.upsertUser(accessToken, refreshToken, profile, function(err, user) {\n        return done(err, user);\n      });\n    }));\n```\n#### Options\n\n* `apiVersion` - Which version of Bitbucket API user want to use. Allowed values are [1.0](https://confluence.atlassian.com/bitbucket/user-endpoint-296092264.html) or [2.0](https://developer.atlassian.com/bitbucket/api/2/reference/resource/user).\n* `accessTokenField` - Name of HTTP header, body field or query parameter where access token is stored in request\n* `refreshTokenField` - Name of HTTP header, body field or query parameter where refresh token is stored in request\n* `passReqToCallback` - Should `verify` function received as first parameter `req` object\n* `profileWithEmail` - If `true` library will try to load profile with all emails that are associated with profile. `email` is scope that is required. If nothing is selected emails will not be loaded.\n\n### Authenticate User\n\n```js\nrouter.route('/auth/bitbucket')\n  .post(passport.authenticate('bitbucket-token'), function(req, res, next) {\n    if (!req.user) {\n      return res.send(401, 'User Not Authenticated');\n    }\n\n    res.send(200);\n  });\n```\n### Client Requests\n\n#### Sending access_token as a Query parameter\n\n```GET /auth/bitbucket?access_token=\u003cTOKEN\u003e```\n\n#### Sending access token as an HTTP header\n\n```\nGET /auth/bitbucket HTTP/1.1\nHost: example.com\nAuthorization: Bearer base64_access_token_string\n```\n\n#### Sending access token as an HTTP body\n\n```\nPOST /auth/bitbucket HTTP/1.1\nHost: example.com\n\naccess_token=base64_access_token_string\n```\n\n### Profile examples\n\nIn this section we will show examples of parsed profile that are returned to `verify` callback.\n\n#### Bitbucket API v1.0\n\n```js\n{ \n  provider: 'bitbucket',\n  id: 'john_doe',\n  username: 'john_doe',\n  name: { first_name: 'John', last_name: 'Doe' },\n  emails: [{value: 'test@example.com', primary: true, verified: true}]\n  avatar: 'https://bitbucket.org/account/john_doe/avatar/32/?ts=1492462087',\n  _raw: 'raw json object from Bitbucket server',\n  _json: \n   { \n     'parsed json object from server'\n   }\n}\n```\n\n#### Bitbucket API v2.0\n\n```js\n{ \n  provider: 'bitbucket',\n  id: 'john_doe',\n  username: 'john_doe',\n  display_name: 'John Doe',\n  emails: [{value: 'test@example.com', primary: true, verified: true}]\n  avatar: 'https://bitbucket.org/account/john_doe/avatar/32/?ts=1492462087',\n  _raw: 'raw json object from Bitbucket server',\n  _json: \n   { \n     'parsed json object from server'\n   }\n}\n```\n\n# Examples\n\nExample of server application can be found [here](https://github.com/GenFirst/passport-bitbucket-token/tree/master/example/backend).\n\nFull example of React.js + Node.js/Express.js can be found [here](https://github.com/GenFirst/react-node-bitbucket-login).\n\n# License\n\npassport-bitbucket-token is released under [MIT License](https://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenfirst%2Fpassport-bitbucket-token","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenfirst%2Fpassport-bitbucket-token","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenfirst%2Fpassport-bitbucket-token/lists"}