From 4ecae23050d99b365b2d8e99bb8523503123a02a Mon Sep 17 00:00:00 2001 From: Guilherme IA Date: Fri, 14 Jul 2017 17:10:37 -0300 Subject: [PATCH] Atualizando para python 3 Modificando forma de gerar o base64 do Basic Authorization. --- moipy/moip.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/moipy/moip.py b/moipy/moip.py index 4692846..27f1878 100644 --- a/moipy/moip.py +++ b/moipy/moip.py @@ -1,5 +1,6 @@ #! /usr/bin/env python # -*- coding: utf-8 -*- + import base64 import pycurl @@ -89,12 +90,11 @@ def envia(self): resposta = RespostaMoIP() passwd = self.token + ":" + self.key - - passwd64 = base64.b64encode(passwd) + passwd64 = base64.b64encode(passwd.encode()) curl = pycurl.Curl() curl.setopt(pycurl.URL,self.url) - curl.setopt(pycurl.HTTPHEADER,["Authorization: Basic " + passwd64]) + curl.setopt(pycurl.HTTPHEADER,["Authorization: Basic " + passwd64.decode('UTF-8')]) curl.setopt(pycurl.USERAGENT,"Mozilla/4.0") curl.setopt(pycurl.USERPWD,passwd) curl.setopt(pycurl.POST,True) @@ -126,4 +126,4 @@ def __init__(self): def callback(self,buf): - self.conteudo = buf \ No newline at end of file + self.conteudo = buf