Giter Site home page Giter Site logo

Comments (4)

dwstevens avatar dwstevens commented on June 14, 2024

I added authentication to my local copy based on this: http://stackoverflow.com/questions/635113/python-urllib2-basic-http-authentication-and-tr-im

bitbucket username and password were hardcoded in the base64string lines... obviously not ideal.

Here's the diff:

diff --git a/migrate.py b/migrate.py
old mode 100644
new mode 100755
index 95e1dda..ef5d5bc
--- a/migrate.py
+++ b/migrate.py
@@ -19,7 +19,7 @@ from datetime import datetime, timedelta
 import urllib2
 import time
 import getpass
-
+import base64
 import sys

 try:
@@ -121,7 +121,10 @@ def get_comments(issue):
     Fetch the comments for an issue
     '''
     url = "https://api.bitbucket.org/1.0/repositories/%s/%s/issues/%s/comments/" % (options.bitbucket_username, options.bitbucket_repo, issu
-    result = json.loads(urllib2.urlopen(url).read())
+    request = urllib2.Request(url)
+    base64string = base64.encodestring('%s:%s' % ('', '')).replace('\n','')
+    request.add_header("Authorization", "Basic %s" % base64string)
+    result = json.loads(urllib2.urlopen(request).read())

     comments = []
     for comment in result:
@@ -143,7 +146,10 @@ issues = []
 while True:
     url = "https://api.bitbucket.org/1.0/repositories/%s/%s/issues/?start=%d" % (options.bitbucket_username, options.bitbucket_repo, options
     try:
-        response = urllib2.urlopen(url)
+       request = urllib2.Request(url)
+       base64string = base64.encodestring('%s:%s' % ('','')).replace('\n','')
+       request.add_header("Authorization", "Basic %s" % base64string)
+       response = urllib2.urlopen(request)
     except urllib2.HTTPError as ex:
         raise ValueError(
             'Problem trying to connect to bitbucket ({url}): {ex} '

from bitbucket-issue-migration.

jeffwidman avatar jeffwidman commented on June 14, 2024

#22 tackles this. Waiting for it to be rebased before merging.

from bitbucket-issue-migration.

jeffwidman avatar jeffwidman commented on June 14, 2024

If a user submits BB creds, but the BB repo is public, then we shouldn't worry about whether the user's BB creds are authentic, we should just use the public API to grab the issues without authenticating.

So probably the workflow is:

  • regardless of whether the user provided BB creds, we should try the BB repo without auth
  • only if we get back a 401 do we check for BB auth creds--if the user didn't include them, then complain
  • if the user included BB auth creds, and we already know it's not a public repo, then we try again to access it
    • if we still get a 404 or 401, complain appropriately to the user

from bitbucket-issue-migration.

jeffwidman avatar jeffwidman commented on June 14, 2024

Fixed in #59

from bitbucket-issue-migration.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.