谷歌云打印服务的访问令牌 [英] access token for google cloud print service

查看:36
本文介绍了谷歌云打印服务的访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的应用程序使用谷歌云打印服务,概念是:买家可以从我的网站购买产品,他应该将订单清单发送到供应商的打印机.

I want to use google cloud print service for my application, Concept is : Buyer can purchase products from my site and he should send order list to supplier's printer.

为此,供应商应在其谷歌帐户中注册打印机,买方将打印请求发送到选定供应商的打印机,订单文件应在供应商的打印机上打印.

For this, Supplier should registor printer in their google account, buyer will send print request to selected supplier's printer, and order document should be printed on supplier's printer.

问题是:云打印应用程序正在使用 OAuth2 身份验证,它需要谷歌帐户登录和 client_id 来获取访问令牌.因此,要获取打印机列表并提交打印作业,买方需要使用来自后端的供应商谷歌凭据从谷歌帐户登录.(有或没有浏览器)这是不可接受的,因为它也将允许买家使用供应商帐户的其他谷歌服务(例如邮件、文档).

Problem is : Cloud print application is using OAuth2 autherization and it requries google account login and client_id to obtain access token. So for geting list of printers and submiting print job, buyer needs to login from google account with the supplier's google credentials from backend. (With or without browser) That's not acceptable as it will also allow buyer to use other google services (e.g. mail,docs) of supplier's account.

所以我的问题是,还有其他方法可以获取访问令牌吗?也欢迎任何其他解决方案.

So my question is , Is there any other method to get access token? Any other solution is also welcome.

注意:我参考了 google-pythonCode云打印 模块.

Note: I have taken reference from google-pythonCode and cloudprinting module.

推荐答案

您想要做的是让供应商使用 OAuth2 进行授权并存储他们的 access_token,更重要的是 refresh_token.买家根本不需要向 Google 授权,您只需使用适当的供应商访问令牌将他们的打印作业发送到供应商打印机即可.这也使处理对不同打印机的访问变得更容易,因为每个供应商的 Google 帐户已经可以访问他们自己的打印机.

What you want to do is to have the suppliers authorize with OAuth2 and store their access_token and more importantly refresh_token. The buyers do not need to authorize with Google at all, you can simply send their print job to the suppliers printer with the appropriate suppliers access token. This also makes it easier to handle the access to the different printers as each suppliers Google account already has access to their own printer.

刷新令牌是一个长期有效的令牌(在被供应商撤销之前一直有效),即使在短期(1 小时)访问令牌到期后,它也允许您获得新的访问令牌.

The refresh token is a long living token (valid until revoked by supplier) that allows you to get new access tokens even after the expiration of the short lived (1 hour) access token.

这篇关于谷歌云打印服务的访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆