我正在使用OAuthlib进行Google的OAuth流程。运行4到5个月效果良好。突然我开始出现以下错误:
File "/home/whitesnow-2/Gaurav/Axonator/AxVirtualEnv/local/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py",
line 409, in validate_token_parameters raise w Warning: Scope has changed from
"https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/docs
https://www.googleapis.com/auth/spreadsheets
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile" to
"https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/docs
https://www.googleapis.com/auth/spreadsheets
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile".
Run Code Online (Sandbox Code Playgroud)
以下是用于生成OAuth授权URL的代码:
flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file(
settings.GOOGLE_OAUTH2_CLIENT_SECRETS_JSON,
scopes=['https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/docs https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile'],
redirect_uri=REDIRECT_URI
)
authorization_url, state = flow.authorization_url(
access_type='offline',
include_granted_scopes='true',
prompt='consent'
)
Run Code Online (Sandbox Code Playgroud)
以下是Google OAuth回调的代码:
auth_code = request.GET.get("code")
objectid = request.GET.get("state")
error = request.GET.get("error")
if error == "access_denied":
return "Access Denied"
else:
flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file(
settings.GOOGLE_OAUTH2_CLIENT_SECRETS_JSON,
scopes=['https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/docs https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile'],
redirect_uri=REDIRECT_URI
)
flow.fetch_token(code=auth_code)
Run Code Online (Sandbox Code Playgroud) python python-2.7 google-oauth google-api-python-client django-1.7
我使用PIL工作时,我在图像上绘制了贝塞尔曲线,我想增加该曲线的厚度.这是我的代码:
for image in images:
img = Image.open("/home/ec2-user/virtualenvs/axonator-production/axonator/media/app_data/ax_picture_20150831_213704.png").convert('RGBA')
for annotation in image["annotations"]:
xys = []
frame = annotation["frame"].split(",")
frame = [int(float(frame[0])),int(float(frame[1])),int(float(frame[2])),int(float(frame[3]))]
frame_location = (frame[0],frame[1])
frame_size = (5000 , 5000)
for point in annotation["path"]:
pt = point["points"].split(",")
xys.append((pt[0],pt[1]))
bezier = make_bezier(xys)
points = bezier(ts)
curve = Image.new('RGBA', frame_size)
import pdb; pdb.set_trace()
curve_draw = ImageDraw.Draw(curve)
curve_draw.polygon(points,outline="red")
curve_draw.text(points[0],str(order))
order = order + 1
img.paste(curve,frame_location,mask = curve)
img.save('out.png')
Run Code Online (Sandbox Code Playgroud)